What is Python? | Uses, features & flavours of Python | Running Python | Identifiers | key words | values & types | Type casting | Operators | Functions | Types of arguments
#Code2Create series: C++ is a powerful general-purpose programming language. It can be used to develop operating systems, browsers, games, and so on. C++ supports different ways of programming like procedural, object-oriented, functional, and so on.Start your programming journey and join us to learn C++ basics!
by Google Developers Group and Women Tech-markers Kuwait chapter:
Instagram and Twitter: @GDGWTMKUWAIT
After the end of lesson you will be able to learn Python basics-What Python is? Its releases. Where we can use Python? Python Features. Tokens, comments variables etc... In out next PPT you will learn how to input and get output in Python
#Code2Create series: C++ is a powerful general-purpose programming language. It can be used to develop operating systems, browsers, games, and so on. C++ supports different ways of programming like procedural, object-oriented, functional, and so on.Start your programming journey and join us to learn C++ basics!
by Google Developers Group and Women Tech-markers Kuwait chapter:
Instagram and Twitter: @GDGWTMKUWAIT
After the end of lesson you will be able to learn Python basics-What Python is? Its releases. Where we can use Python? Python Features. Tokens, comments variables etc... In out next PPT you will learn how to input and get output in Python
Introduction to C Language - Version 1.0 by Mark John LadoMark John Lado, MIT
The C programming language is a general-purpose, high – level language (generally denoted as structured language). C programming language was at first developed by Dennis M. Ritchie at At&T Bell Labs.
C is one of the most commonly used programming languages. It is simple and efficient therefore it becomes best among all. It is used in all extents of application, mainly in the software development.
Many software's & applications as well as the compilers for the other programming languages are written in C also Operating Systems like Unix, DOS and windows are written in C.
C has many powers, it is simple, stretchy and portable, and it can control system hardware easily. It is also one of the few languages to have an international standard, ANSI C.
This presentation provides the information on python including the topics Python features, applications, variables and operators in python, control statements, numbers, strings, print formatting, list and list comprehension, dictionaries, tuples, files, sets, boolean, mehtods and functions, lambda expressions and a sample project using Python.
Kosmik is the best institute for Python training in Hyderabad Kukatpally/KPHB. kosmik provides lab facilities with complete real-time training with live sessions
call now: +91-8712186898, +91-8179496603, +91-6309565721
ZENUS INFOTECH is best Python Training institute in Roorkee and an ISO 9001:2008 Certified Engineer’s Training Company in Roorkee & provides training to the B.E./B.TECH/DIPLOMA/MCA/BCA and related field students in 35+ cutting-edge technologies like AutoCAD, Solid-Works, CATIA, REVIT, Pro-E, UG-NX .NET, JAVA, PHP, GST Tally and Wireless & Telecommunication and many more.
OS | Functions of OS | Operations of OS | Operations of a process | Scheduling algorithms | FCFS scheduling | SJF scheduling | RR scheduling | Paging | File system implementation | Cryptography as a security tool
Problem | Problem v/s Algorithm v/s Program | Types of Problems | Computational complexity | P class v/s NP class Problems | Polynomial time v/s Exponential time | Deterministic v/s non-deterministic Algorithms | Functions of non-deterministic Algorithms | Non-deterministic searching Algorithm | Non-deterministic sorting Algorithm | NP - Hard and NP - Complete Problems | Reduction | properties of reduction | Satisfiability problem and Algorithm
More Related Content
Similar to Introduction to python programming ( part-1)
Introduction to C Language - Version 1.0 by Mark John LadoMark John Lado, MIT
The C programming language is a general-purpose, high – level language (generally denoted as structured language). C programming language was at first developed by Dennis M. Ritchie at At&T Bell Labs.
C is one of the most commonly used programming languages. It is simple and efficient therefore it becomes best among all. It is used in all extents of application, mainly in the software development.
Many software's & applications as well as the compilers for the other programming languages are written in C also Operating Systems like Unix, DOS and windows are written in C.
C has many powers, it is simple, stretchy and portable, and it can control system hardware easily. It is also one of the few languages to have an international standard, ANSI C.
This presentation provides the information on python including the topics Python features, applications, variables and operators in python, control statements, numbers, strings, print formatting, list and list comprehension, dictionaries, tuples, files, sets, boolean, mehtods and functions, lambda expressions and a sample project using Python.
Kosmik is the best institute for Python training in Hyderabad Kukatpally/KPHB. kosmik provides lab facilities with complete real-time training with live sessions
call now: +91-8712186898, +91-8179496603, +91-6309565721
ZENUS INFOTECH is best Python Training institute in Roorkee and an ISO 9001:2008 Certified Engineer’s Training Company in Roorkee & provides training to the B.E./B.TECH/DIPLOMA/MCA/BCA and related field students in 35+ cutting-edge technologies like AutoCAD, Solid-Works, CATIA, REVIT, Pro-E, UG-NX .NET, JAVA, PHP, GST Tally and Wireless & Telecommunication and many more.
OS | Functions of OS | Operations of OS | Operations of a process | Scheduling algorithms | FCFS scheduling | SJF scheduling | RR scheduling | Paging | File system implementation | Cryptography as a security tool
Problem | Problem v/s Algorithm v/s Program | Types of Problems | Computational complexity | P class v/s NP class Problems | Polynomial time v/s Exponential time | Deterministic v/s non-deterministic Algorithms | Functions of non-deterministic Algorithms | Non-deterministic searching Algorithm | Non-deterministic sorting Algorithm | NP - Hard and NP - Complete Problems | Reduction | properties of reduction | Satisfiability problem and Algorithm
What is Endoscopy?
What are the complications of Endoscopy?
How Capsule endoscopy overcomes those problems?
What are the components of the capsule?
How does it works ?
Quarkus Hidden and Forbidden ExtensionsMax Andersen
Quarkus has a vast extension ecosystem and is known for its subsonic and subatomic feature set. Some of these features are not as well known, and some extensions are less talked about, but that does not make them less interesting - quite the opposite.
Come join this talk to see some tips and tricks for using Quarkus and some of the lesser known features, extensions and development techniques.
Designing for Privacy in Amazon Web ServicesKrzysztofKkol1
Data privacy is one of the most critical issues that businesses face. This presentation shares insights on the principles and best practices for ensuring the resilience and security of your workload.
Drawing on a real-life project from the HR industry, the various challenges will be demonstrated: data protection, self-healing, business continuity, security, and transparency of data processing. This systematized approach allowed to create a secure AWS cloud infrastructure that not only met strict compliance rules but also exceeded the client's expectations.
How to Position Your Globus Data Portal for Success Ten Good PracticesGlobus
Science gateways allow science and engineering communities to access shared data, software, computing services, and instruments. Science gateways have gained a lot of traction in the last twenty years, as evidenced by projects such as the Science Gateways Community Institute (SGCI) and the Center of Excellence on Science Gateways (SGX3) in the US, The Australian Research Data Commons (ARDC) and its platforms in Australia, and the projects around Virtual Research Environments in Europe. A few mature frameworks have evolved with their different strengths and foci and have been taken up by a larger community such as the Globus Data Portal, Hubzero, Tapis, and Galaxy. However, even when gateways are built on successful frameworks, they continue to face the challenges of ongoing maintenance costs and how to meet the ever-expanding needs of the community they serve with enhanced features. It is not uncommon that gateways with compelling use cases are nonetheless unable to get past the prototype phase and become a full production service, or if they do, they don't survive more than a couple of years. While there is no guaranteed pathway to success, it seems likely that for any gateway there is a need for a strong community and/or solid funding streams to create and sustain its success. With over twenty years of examples to draw from, this presentation goes into detail for ten factors common to successful and enduring gateways that effectively serve as best practices for any new or developing gateway.
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Hivelance Technology
Cryptocurrency trading bots are computer programs designed to automate buying, selling, and managing cryptocurrency transactions. These bots utilize advanced algorithms and machine learning techniques to analyze market data, identify trading opportunities, and execute trades on behalf of their users. By automating the decision-making process, crypto trading bots can react to market changes faster than human traders
Hivelance, a leading provider of cryptocurrency trading bot development services, stands out as the premier choice for crypto traders and developers. Hivelance boasts a team of seasoned cryptocurrency experts and software engineers who deeply understand the crypto market and the latest trends in automated trading, Hivelance leverages the latest technologies and tools in the industry, including advanced AI and machine learning algorithms, to create highly efficient and adaptable crypto trading bots
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Globus
The U.S. Geological Survey (USGS) has made substantial investments in meeting evolving scientific, technical, and policy driven demands on storing, managing, and delivering data. As these demands continue to grow in complexity and scale, the USGS must continue to explore innovative solutions to improve its management, curation, sharing, delivering, and preservation approaches for large-scale research data. Supporting these needs, the USGS has partnered with the University of Chicago-Globus to research and develop advanced repository components and workflows leveraging its current investment in Globus. The primary outcome of this partnership includes the development of a prototype enterprise repository, driven by USGS Data Release requirements, through exploration and implementation of the entire suite of the Globus platform offerings, including Globus Flow, Globus Auth, Globus Transfer, and Globus Search. This presentation will provide insights into this research partnership, introduce the unique requirements and challenges being addressed and provide relevant project progress.
Accelerate Enterprise Software Engineering with PlatformlessWSO2
Key takeaways:
Challenges of building platforms and the benefits of platformless.
Key principles of platformless, including API-first, cloud-native middleware, platform engineering, and developer experience.
How Choreo enables the platformless experience.
How key concepts like application architecture, domain-driven design, zero trust, and cell-based architecture are inherently a part of Choreo.
Demo of an end-to-end app built and deployed on Choreo.
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Shahin Sheidaei
Games are powerful teaching tools, fostering hands-on engagement and fun. But they require careful consideration to succeed. Join me to explore factors in running and selecting games, ensuring they serve as effective teaching tools. Learn to maintain focus on learning objectives while playing, and how to measure the ROI of gaming in education. Discover strategies for pitching gaming to leadership. This session offers insights, tips, and examples for coaches, team leads, and enterprise leaders seeking to teach from simple to complex concepts.
We describe the deployment and use of Globus Compute for remote computation. This content is aimed at researchers who wish to compute on remote resources using a unified programming interface, as well as system administrators who will deploy and operate Globus Compute services on their research computing infrastructure.
top nidhi software solution freedownloadvrstrong314
This presentation emphasizes the importance of data security and legal compliance for Nidhi companies in India. It highlights how online Nidhi software solutions, like Vector Nidhi Software, offer advanced features tailored to these needs. Key aspects include encryption, access controls, and audit trails to ensure data security. The software complies with regulatory guidelines from the MCA and RBI and adheres to Nidhi Rules, 2014. With customizable, user-friendly interfaces and real-time features, these Nidhi software solutions enhance efficiency, support growth, and provide exceptional member services. The presentation concludes with contact information for further inquiries.
Modern design is crucial in today's digital environment, and this is especially true for SharePoint intranets. The design of these digital hubs is critical to user engagement and productivity enhancement. They are the cornerstone of internal collaboration and interaction within enterprises.
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamtakuyayamamoto1800
In this slide, we show the simulation example and the way to compile this solver.
In this solver, the Helmholtz equation can be solved by helmholtzFoam. Also, the Helmholtz equation with uniformly dispersed bubbles can be simulated by helmholtzBubbleFoam.
First Steps with Globus Compute Multi-User EndpointsGlobus
In this presentation we will share our experiences around getting started with the Globus Compute multi-user endpoint. Working with the Pharmacology group at the University of Auckland, we have previously written an application using Globus Compute that can offload computationally expensive steps in the researcher's workflows, which they wish to manage from their familiar Windows environments, onto the NeSI (New Zealand eScience Infrastructure) cluster. Some of the challenges we have encountered were that each researcher had to set up and manage their own single-user globus compute endpoint and that the workloads had varying resource requirements (CPUs, memory and wall time) between different runs. We hope that the multi-user endpoint will help to address these challenges and share an update on our progress here.
A Comprehensive Look at Generative AI in Retail App Testing.pdfkalichargn70th171
Traditional software testing methods are being challenged in retail, where customer expectations and technological advancements continually shape the landscape. Enter generative AI—a transformative subset of artificial intelligence technologies poised to revolutionize software testing.
Why React Native as a Strategic Advantage for Startup Innovation.pdfayushiqss
Do you know that React Native is being increasingly adopted by startups as well as big companies in the mobile app development industry? Big names like Facebook, Instagram, and Pinterest have already integrated this robust open-source framework.
In fact, according to a report by Statista, the number of React Native developers has been steadily increasing over the years, reaching an estimated 1.9 million by the end of 2024. This means that the demand for this framework in the job market has been growing making it a valuable skill.
But what makes React Native so popular for mobile application development? It offers excellent cross-platform capabilities among other benefits. This way, with React Native, developers can write code once and run it on both iOS and Android devices thus saving time and resources leading to shorter development cycles hence faster time-to-market for your app.
Let’s take the example of a startup, which wanted to release their app on both iOS and Android at once. Through the use of React Native they managed to create an app and bring it into the market within a very short period. This helped them gain an advantage over their competitors because they had access to a large user base who were able to generate revenue quickly for them.
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Anthony Dahanne
Les Buildpacks existent depuis plus de 10 ans ! D’abord, ils étaient utilisés pour détecter et construire une application avant de la déployer sur certains PaaS. Ensuite, nous avons pu créer des images Docker (OCI) avec leur dernière génération, les Cloud Native Buildpacks (CNCF en incubation). Sont-ils une bonne alternative au Dockerfile ? Que sont les buildpacks Paketo ? Quelles communautés les soutiennent et comment ?
Venez le découvrir lors de cette session ignite
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...informapgpstrackings
Keep tabs on your field staff effortlessly with Informap Technology Centre LLC. Real-time tracking, task assignment, and smart features for efficient management. Request a live demo today!
For more details, visit us : https://informapuae.com/field-staff-tracking/
Experience our free, in-depth three-part Tendenci Platform Corporate Membership Management workshop series! In Session 1 on May 14th, 2024, we began with an Introduction and Setup, mastering the configuration of your Corporate Membership Module settings to establish membership types, applications, and more. Then, on May 16th, 2024, in Session 2, we focused on binding individual members to a Corporate Membership and Corporate Reps, teaching you how to add individual members and assign Corporate Representatives to manage dues, renewals, and associated members. Finally, on May 28th, 2024, in Session 3, we covered questions and concerns, addressing any queries or issues you may have.
For more Tendenci AMS events, check out www.tendenci.com/events
2. Contents
• What is Python?
• Uses, features & flavours of Python
• Running Python
• Identifiers
• key words
• values & types
• Type casting
• Operators
• Functions
• Types of arguments
3. What is Python?
Python is a simple, general purpose, high level, Dynamic, Interpreted and object-
oriented programming language.
Python was developed by Guido Van Rossam in 1989 while working at National
Research Institute at Netherlands.
But officially python was made available to public in 1991. The official Date of
Birth for python is: Feb 20th 1991.
Guido developed python program language by taking almost all programming
features from different languages:
1. Functional Programming Features from C.
2. Object Oriented Programming Features from C++.
4. Uses of Python:
We can use everywhere .The most common important Application
areas are:
1. For developing Desktop Applications.
2. For developing Web Applications.
3. For developing Database Applications.
4. For developing Network programming Applications.
5. For developing Games.
6. For Data Analysis Applications.
7. For Machine Learning.
8. For developing Artificial Intelligence Applications.
9. For IoT etc.
5. Features of Python:
1. Simple and easy to learn
2. Freeware and Open Source
3. High Level Programming Language
4. Platform Independent
5. Portability
6. Dynamically Typed
7. Both procedure Oriented and Object Oriented
8. Interpreted
9. Extensible
10. Embedded
11. Extensive Library
Versions of Python :
Python 1.0 in Jan 1994.
Python 2.0 in Oct 2000.
Python 3.0 in Dec 2008.
6. Flavors of Python:
NO Flavor description
1 Cpython It is the standard flavor of Python. It can be used to work with C language
Applications.
2 Jython (or) Jpython It is for Java Applications. It can run on JVM.
3 IronPython It is for C#.Net Platform.
4 PyPy The main advantage of PyPy is performance will be improved because JIT
compiler is Available inside PVM.
5 RubyPython For Ruby Platforms
6 AnacondaPython It is specially designed for handling large volume of data processing.
7. We Run Python Script in the following
ways:
1.Interactive Mode
2.Command Line
3.IDE Mode
1. Interactive Mode:
To enter in an interactive mode,
you will have to open Command
Prompt on your windows machine and
type ‘python’ and press Enter.
Running Python :
8. 2. Script Mode:
Using Script Mode, we can write our Python code in a separate file of any
editor in our Operating System.
Save it by .py extension.
Now open Command prompt and execute it by : python filename.py
Ex: python hello.py
You can write your own file name in place of ‘hello.py’.
9. 3.Using IDE (Integrated Development Environment):
We can execute our Python code using a Graphical User Interface (GUI).
All you need to do is:
Click on Start button -> All Programs -> Python -> IDLE(Python GUI)
Python Shell will be opened. Now click on File -> New Window.
A new Editor will be opened. Write our Python code here.
10. Identifiers :
A Name in python program is called Identifier
It can be variable Name (OR) Class Name (OR) Function Name
EX: a=10
Rules to Define Identifier in Python:
1. The only allowed characters in python are:
Alphabet symbols(Either lower or Upper case)
Digits(0 to 9)
Underscore Symbol(_)
2. Identifier should not start with Digit.
3.Identifers are Case Sensitive.
11. Reserved words ( or ) Key words :
Python Keywords are special reserved words that convey a special meaning
to the compiler/interpreter.
Each keyword has a special meaning and a specific operation.
These keywords can't be used as a variable.
Following is the List of Python Keywords.
True False None and as
asset def class continue break
else finally elif del except
global for if from import
raise try or return pass
nonlocal in not is lambda
12. Value and Types:
Value:
A value is one of the basic thing in a
program ,like a letter or a number.
Some values we have seen so far are
2, 42.0, and 'Hello, World!’.
These values belong to different
types:
Ex: 2 is an integer, 42.0 is a floating-
point number, and 'Hello, World!' is a
string
Types:
Data Type Represents the type of value
present inside a Variable.
In python we are not required to
specify the type explicitly. Based on Value
assigned the type will be assigned
automatically. Hence python is dynamic
typed language.
Python Contains the following inbuilt
Data Types:
1.Int
2.Float
3.Complex
4.Bool
5.Str
13. 1.int:
int data type is used to represent whole numbers(integral values)
Ex: a=10
type(a) #int
We can represent int values in the following ways:
1.Decimal form
2.Binary form
3.Octal form
4.Hexa Decimal form
14. 1.Decimal Form (Base-10):
It is the default number system.
The allowed digits are: 0 to 9
Ex: a=10
2. Binary Form (Base-2):
The allowed digits are: 0 & 1
Value should be prefixed with 0b or
0B.
Ex: a=0B1111
3.Octal Form (Base-8):
The allowed digits are: 0 to 7
Value should be prefixed with 0o or
0O
Ex: 0o123
4. Hexa Decimal Form ( Base -16):
The allowed digits are:0 to 9, a-f
(both lower and upper cases).
Values should be prefixed with 0x or 0X.
EX: a=0x10
15. 2.float :
float data type is used to represent floating point values(decimal values)
Ex: f=1.234
type(f) #float
3. complex :
A complex number is of the form a+bj
Complex numbers are specified as <real part>+<imaginary part>j.
Note: ‘a’ and ‘b’ contain integers (or) floating point values.
EX: 3+5j
10+5.5j
0.5 + 0.1j
16. 4.bool :
We can use this data type to represent Boolean values.
The only allowed values for this data type are: True and False
Internally python represents True as 1 and False as 0.
EX: b=True
type(b) -> bool
5.str :
A String is a sequence of characters enclosed within single /double quotes.
EX: s1=‘Hello’
s2=“Welcome”
By using single or double quotes we can’t represent multi line string.
17. Type Casting :
Conversion of one type value to another is called typecasting.
The following are various inbuilt functions for type casting:
function input output
1.int() int(123.987) 123
2.float() float(10) 10.0
3.complex() complex(10) 10+0j
4.bool() bool(1) True
5.str() str(10) ‘10’
18. Assignment Statements:
An assignment statement creates a new variable and gives it a value
Ex: message = 'And now for something completely different’
n = 17
pi = 3.1415926535897932
This example makes three assignments. The first assigns a string to a new
variable named message.
the second gives the integer 17 to n.
the third assigns the (approximate) value of π to pi.
19. Operators:
Operator is a Symbol that perform certain operations.
Python provide the following Operators:
1.Arithmatic Operators
2.Relational Operators (or) Comparison Operators.
3.Logical Operators.
4.Bitwise Operators.
5. Assignment Operators.
6.Special Operators.
20. 1. Arithmetic operators:
Python provides operators, which are special symbols that represent certain
operations like addition and multiplication etc.
One of the operator is Arithmetic operators.
Arithmetic Operators are:
1) + -> Addition
2) - -> Subtraction
3) * -> Multiplication
4) / -> Division
5) % -> Modulation
6) // -> Floor Division
7) ** -> Exponent (OR) Power Operator
22. 2.Relatonal (OR) Comparison Operators:
Comparison operators are used to comparing the value of the two operands and
returns Boolean true or false.
They return true if the condition is satisfied otherwise the return false.
Operator Description
== If the value of two operands is equal, then the condition becomes true.
!= If the value of two operands is not equal then the condition becomes true.
<= If the first operand is less than or equal to the second operand, then the
condition becomes true.
>= If the first operand is greater than or equal to the second operand, then the
condition becomes true.
<> If the value of two operands is not equal, then the condition becomes true.
> If the first operand is greater than the second operand, then the condition
becomes true.
< If the first operand is less than the second operand, then the condition
becomes true.
23. Example :
a = 13
b = 33
print(a > b)
print(a < b)
print(a == b)
print(a != b)
print(a >= b)
print(a <= b)
print(a<>b)
Output:
False
True
False
True
False
True
True
We can also apply relational
operators for str types also.
Example :
a=“hello”
b=“hello”
print(“a>b is”, a>b)
print(“a>b is”, a>=b)
print(“a>b is”, a<b)
print(“a>b is”, a<=b)
Output :
a>b is False
a>=b is True
a<b is False
a<=b True
24. 3.Logical Operators:(and,or,not)
The logical operators are used primarily in the expression evaluation to make
a decision.
1.For Boolean Types:
Operator Description
and If both the expression are true, then the condition will be true. If a and b are the two
expressions, a → true, b → true => a and b → true.
Or If one of the expressions is true, then the condition will be true. If a and b are the two
expressions, a → true, b → false => a or b → true.
Not If an expression a is true then not (a) will be false and vice versa.
Example :
a=10
b=20
c=5
if a>b and a>c:
print(“ a is biggest”)
elif b>c:
print(“b Is biggest”)
else:
print(“c is biggest”)
Output :
b is biggest
25. 2.For non Boolean types:
X and Y:
If x is evaluates to false return X otherwise return Y.
Ex: 10 and 20 -> 20
0 and 20 -> 0
X or Y:
If x is evaluates to True return X otherwise return Y.
Ex: 10 and 20 ->10
0 or 20 ->20
not X :
0 means ->False
Non-zero means -> True
Empty string means -> False
If x is evaluates to False Then result is True otherwise False.
Ex : not 10 ->False
not 0 ->True
26. 4.Bitwse Operators:
The bitwise operators perform bit by bit operation on the values of the two
operands.
Operator Description
& (binary and) If both the bits at the same place in two operands are 1, then 1 is copied
to the result. Otherwise, 0 is copied.
| (binary or) The resulting bit will be 0 if both the bits are zero otherwise the resulting
bit will be 1.
^ (binary xor) The resulting bit will be 1 if both the bits are different otherwise the
resulting bit will be 0.
~ (negation) It calculates the negation of each bit of the operand, i.e., if the bit is 0, the
resulting bit will be 1 and vice versa.
<< (left shift) The left operand value is moved left by the number of bits present in the
right operand.
>> (right shift) The left operand is moved right by the number of bits present in the right
operand.
Program:
a = 10
b = 4
print(a & b)
print(a | b)
print(~a)
print(a ^ b)
print(a >> 2)
print(a << 2)
Output:
0
14
-11
14
2
40
27. 5.Assignment Operators:
The assignment operators are used to assign the value of the right expression
to the left operand.
perator Description Example
= Assigns values from right side operands to left side operand c = a + b assigns value of
a + b into c
+= Add AND It adds right operand to the left operand and assign the result to left
operand
c += a is equivalent to c =
c + a
-= Subtract AND It subtracts right operand from the left operand and assign the result to left
operand
c -= a is equivalent to c =
c - a
*= Multiply AND It multiplies right operand with the left operand and assign the result to left
operand
c *= a is equivalent to c =
c * a
/= Divide AND It divides left operand with the right operand and assign the result to left
operand
c /= a is equivalent to c =
c / ac /= a is equivalent
to c = c / a
%= Modulus AND It takes modulus using two operands and assign the result to left operand c %= a is equivalent to c =
c % a
**= Exponent AND Performs exponential (power) calculation on operators and assign value to
the left operand
c **= a is equivalent to c
= c ** a
//= Floor Division It performs floor division on operators and assign value to the left operand c //= a is equivalent to c
= c // a
Program :
a = 21
b = 10
c = 0
c = a + b
print "Line 1 - Value of c is ", c
c += a
print "Line 2 - Value of c is ", c
c *= a
print "Line 3 - Value of c is ", c
c /= a
print "Line 4 - Value of c is ", c
c = 2
c %= a
print "Line 5 - Value of c is ", c
c **= a
print "Line 6 - Value of c is ", c
c //= a
print "Line 7 - Value of c is ", c
28. 6.Special Operators:
1.Identity Operators:
We can use identity operators for
address comparison.
the identity operators both are used
to check if two values are refer the
same part of the memory. It return
True (or) False
2.Membership Operators:
We can use Membership operators to
check whether the given object
present in the given collection.(It may
be string ,list,Tuple or Dict)
Operator Description
is It is evaluated to be true if the
reference present at both sides
point to the same object.
is not It is evaluated to be true if the
reference present at both sides do
not point to the same object.
Operator Description
in It is evaluated to be True if value is
found in the sequence (list, tuple,
or dictionary).
not in It is evaluated to be True if value is
not found in the sequence (list,
tuple, or dictionary).
29. Ex:
X=“hello learning python is very easy”
print(‘h’ in X) ->True
print(‘d’ in X) -> False
print(‘d’ not in X) -> True
Print(‘python’ in X) ->True
Ex:
list1=[“sunny”,”bunny”,”chinny”,”pinny”]
print(“sunny” in list1) -> True
print(“tunny” in list1) -> False
print(“tunny” not in list1) -> True
30. String Operations: ( + , * )
The + operator performs string
concatenation, which means it joins
the strings by linking them end-to-
end.
Example:
first = 'throat'
second = 'warbler’
Print( first + second)
Output :
throatwarbler
The * operator also works on
strings; it performs repetition.
Example:
Print( 'Spam'*3)
Output :
'SpamSpamSpam'
31. Functions :
What is Function: Function is a Block of code to perform specific Operation, it
only runs when it is called.
we can pass data to functions Known as parameters.
A Functions can return data as result.
Why Functions:
Easy to Understand
Easy to Read
Easy to Debug
Code Reusability
Functions can make a program smaller by eliminating repetitive code. Later, if
you make a change, you only have to make it in one place.
32. Types Of Functions:
Python supports 2 types of functions:
1.Built in Functions
2.User Defined Functions
1.Built in Functions:
The functions which are coming along with python software automatically, are
called built in functions (or) predefined functions.
Ex :
id()
type()
input()
print()
eval()
33. 2.User Defined Functions:
The functions which are developed by programmer explicitly according to
business requirements are called user defined functions.
Syntax to create user defined functions:
def function_name(parameters):
function Block
return value
In python a functions is defined using “def” Keyword
A function accepts the parameter (argument), and they can be optional.
The function block is started with the colon (:), and block statements must
be at the same indentation.
The return statement is used to return the value. A function can have only
one return
Program :
def hello_world():
print(“hello world”)
hello_world()
function call
34. Math Functions:
Python has a math module that provides most of the familiar mathematical
functions.
A module is a file that contains a collection of related functions.
Before we can use the functions in a module, we have to import it with an
import statement:
import modulename
EX: import math
This statement creates a module object named math.
we can access members by using module name.
modulename.variable
modulename.function()
Ex: import math
s=math.sqrt(4)
print(s)
Output : 2
35. Module Aliasing:
Syntax: import modulename as aliasname
Ex: import math as m
original module name alias name.
Ex: import math as m
s=m.sqrt(4)
print(s)
Output : 2
Member Aliasing:
Syntax:
from modulename import module1 as
aliasname,moule2 as aliasname,….
Ex:
from math import sqrt as st, pow as pw
Ex :
s=st(4)
p=pw(2,2)
print(s)
print(p)
36. Coposition :
So far, we have looked at the elements of a program—variables, expressions, and
statements.
One of the most useful features of programming languages is their ability to take
small building blocks and compose them.
For example, the argument of a function can be any kind of expression, including
arithmetic operators:
x = math.sin(degrees / 360.0 * 2 * math.pi)
And even function calls:
x = math.exp(math.log(x+1))
Almost anywhere you can put a value, you can put an arbitrary expression, with
one exception: the left side of an assignment statement has to be a variable
name.
Any other expression on the left side is a syntax error (we will see exceptions to
this rule later).
minutes = hours * 60 # right
37. FLOW OF EXECUTION:
To ensure that a function is defined before its first use, you have to know the
order statements run in, which is called the flow of execution.
Execution always begins at the first statement of the program. Statements are
run one at a time, in order from top to bottom.
Function definitions do not alter the flow of execution of the program, but
remember that statements inside the function don’t run until the function is
called.
38. Parameters and Arguments:
Parameters are inputs to the function. if a function contains
parameters, then at the time of calling, compulsory we should provide
values otherwise, otherwise we will get error.
Ex: Write a function to take name of the student as input and print
message by name.
def wish(name):
print(“ Hi”,name,”you look Gorgeous !”)
wish(“ Selena”)
wish(“ Lisa”)
Output :
Hi Selena you look Gorgeous !
Hi Lisa you look Gorgeous !
39. Types of arguments:
def f1(a,b):
satement1
statement2
:
:
statement
f1(10,20)
There are 4 types of actual arguments in python:
1.positional Arguments
2.Keyword Arguments
3.Default Arguments
4.Variable Length Arguments
Formal arguments
Actual arguments
40. 1.Positional Arguments:
These are the arguments passed to function in correct positional order.
EX: def add(a,b):
print(a+b)
add(10,20)
add(100,200)
OUTPUT: 30
300
The number of arguments and position of arguments must be matched. if we
change the order then result may be changed.
If we change the number of arguments then we will get error.
41. 2.Keyword Arguments:
We can pass argument values by keyword i.e by parameter name.
EX: def wish(name,msg):
print(“Hello”name,msg)
wish(name=“Selena ”,msg=“Good Morning”)
wish(msg=“Good Morning”,name=“ Selena ”)
OUTPUT:
Hello Selena Good Morning
Hello Selena Good Morning
Here the order of arguments is not important but the number of arguments
must be matched.
42. 3.Default Arguments:
Some times we can provide default values for our positional
arguments.
EX:
def wish(name=“Guest ”):
print(“hello”,name,”good morning”)
wish(“Selena”)
wish()
OUTPUT:
Hello Selena good morning
Hello Guest good morning
If we are not passing any name then only default value will be
considered.
43. 4.Vaiable Length Arguments:
Some times we can pass variable number of arguments to our function, such
type of arguments are called variable length arguments.
We can declare a variable length arguments with * symbol as follows.
EX: def f1(*N):
EX: def sum(*n):
total=0
for i in n:
total=total+n
print(“the sum =”,total)
sum()
sum(10)
sum(10,20)
sum(10,20,30,40)
OUTPUT:
the sum=0
the sum=10
the sum=30
the sum=100
44. Variables and Parameters are local:
1.Local Variables:
The variables which are declared inside a
function are called local variables.
Local variables are available only for the
function in which we declared it. i.e from out
side of function we cannot access.
EX:
def f1():
a=10 ->Local variable
print(a) -> valid
def f2():
print(a) ->Invalid
f1()
f2()
NameError: name ‘a’ is not defined
2. Global Variables :
The variables which are declared
out side of function are called global
variables.
These variables can be accessed in
all functions of that module.
EX:
a=10 -> global variable
def f1():
print(a) -> valid
def f2():
print(a) ->valid
f1()
f2()
45. Fruitful Functions : Void Functions:
Which are the functions return
values are called fruitful functions.
The function return values by
executing “return” statement.
EX: def f1(a,b):
c=a+b
return c
sum=f1(10,20)
print(sum)
OUTPUT:
30
Which are the functions are not
return values are called void functions
.
EX:
def f1(a,b):
c=a+b
print( c )
f1(10,20)
OUTPUT:
30