What is Python? | Uses, features & flavours of Python | Running Python | Identifiers | key words | values & types | Type casting | Operators | Functions | Types of arguments
The document provides an overview of the Python programming language. It discusses why Python is useful for students and professionals, its major features like being object-oriented and having a large standard library. The document also covers Python's history, how to install it and set the environment variables, basic syntax like variables and data types, operators, and common programming constructs like conditionals and loops.
This document provides an industrial training presentation on Python programming. It introduces Python, explaining that it is an interpreted, object-oriented, high-level programming language. It then covers why Python is used, its basic data types like numbers, strings, lists, dictionaries, tuples and sets. The presentation also discusses Python concepts like conditionals, loops, functions, exceptions, file handling, object-oriented programming and databases. It concludes that Python supports both procedural and object-oriented programming and can be universally accepted. References for further reading are also included.
This document provides an introduction and overview of the Python programming language. It discusses Python's key features such as being an interpreted, object-oriented, high-level programming language with dynamic typing and a large standard library. It also covers Python's use as both a scripting and general purpose language. The document then discusses Python's data types, operators, control flow statements, functions, and lambda expressions. It provides examples of using Python interactively and in script mode.
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.
This document provides an introduction and overview of the Python programming language course CSE 120 handled by G.Gandhi Jaba Kumar. It discusses that Python is an interpreted, object-oriented, and interactive programming language used for web development, software development, mathematics, and system scripting. The document then covers Python syntax including indentation, comments, keywords, variables, data types, operators, and basic programming concepts like conditionals and loops. It provides examples to illustrate Python code and best practices.
Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. It was created by Guido van Rossum in 1991 and named after the BBC show Monty Python's Flying Circus. Python is used for web development, data analysis, scientific computing, and more. It has a simple syntax and is highly readable. Key features of Python include object orientation, dynamic typing, automatic memory management, and a large standard library. Common uses of Python include data science, web development, education, systems administration, and more. Major companies that use Python include Google, Facebook, NASA, and Netflix.
This document provides an introduction to the Python programming language. It discusses Python's design philosophy emphasizing readability. It also covers printing messages, reading input, variables and data types, operators, and basic syntax like comments and identifiers. Arithmetic, relational, logical and bitwise operators are explained along with examples.
This document provides an introduction to the Python programming language. It discusses Python's design philosophy emphasizing readability. It also covers printing messages, reading input, variables and data types, operators, and basic syntax like comments and identifiers. Arithmetic, relational, logical and bitwise operators are explained along with examples.
This document discusses programming languages, compilers vs interpreters, and introduces Python. It explains that a programming language communicates instructions to a machine and can be used to create programs. An interpreter reads and executes code directly, while a compiler converts source code into machine code. Python is an interpreted, object-oriented language that is easy to learn yet powerful. It can be used for web, enterprise, and other applications. The document also provides basic information on Python syntax and data types.
The document provides an introduction to Python programming, including details about Python's history, versions, data types, strings, and code execution. It discusses how to install Python and write basic programs. Key reasons for using Python are its object-oriented nature, readability, large standard library, cross-platform capabilities, and ease of use. The document also covers string methods and slicing, numeric data types, installing Python, and running code in interactive and script modes.
Basic concept of Python.pptx includes design tool, identifier, variables.supriyasarkar38
This document discusses Python programming concepts including data types, variables, operators, and functions. It provides examples of Python syntax for writing and executing code as well as built-in data types like strings, integers, and lists. Key concepts covered include variables, data type casting, comments, arithmetic and comparison operators, and functions.
Introduction to Python for Data Science and Machine Learning ParrotAI
This document provides an introduction and overview of Python for data science and machine learning. It covers basics of Python including what Python is, its features, why it is useful for data science. It also discusses installing Python, using the IDLE and Jupyter Notebook environments. The document then covers Python basics like variables, data types, operators, decision making and loops. Finally, it discusses collection data types like lists, tuples and dictionaries and functions in Python.
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.
This document provides a high-level summary of an introduction to Python programming course. The summary includes an overview of Python basics like variables, data types, operators, conditionals, loops, functions and file handling. It also discusses commonly used Python libraries and concepts in data analytics like NumPy, Pandas, Matplotlib and statistics.
This document provides an overview and introduction to Python programming. It discusses Python basics like variables, data types, operators, conditionals, loops, functions and file handling. It also covers commonly used Python libraries and concepts in data analytics like NumPy, Pandas, Matplotlib and statistics. The document is intended as a whistle-stop tour to cover the most common aspects of Python.
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) (20)
This document provides an introduction to the Python programming language. It discusses Python's design philosophy emphasizing readability. It also covers printing messages, reading input, variables and data types, operators, and basic syntax like comments and identifiers. Arithmetic, relational, logical and bitwise operators are explained along with examples.
This document provides an introduction to the Python programming language. It discusses Python's design philosophy emphasizing readability. It also covers printing messages, reading input, variables and data types, operators, and basic syntax like comments and identifiers. Arithmetic, relational, logical and bitwise operators are explained along with examples.
This document discusses programming languages, compilers vs interpreters, and introduces Python. It explains that a programming language communicates instructions to a machine and can be used to create programs. An interpreter reads and executes code directly, while a compiler converts source code into machine code. Python is an interpreted, object-oriented language that is easy to learn yet powerful. It can be used for web, enterprise, and other applications. The document also provides basic information on Python syntax and data types.
The document provides an introduction to Python programming, including details about Python's history, versions, data types, strings, and code execution. It discusses how to install Python and write basic programs. Key reasons for using Python are its object-oriented nature, readability, large standard library, cross-platform capabilities, and ease of use. The document also covers string methods and slicing, numeric data types, installing Python, and running code in interactive and script modes.
Basic concept of Python.pptx includes design tool, identifier, variables.supriyasarkar38
This document discusses Python programming concepts including data types, variables, operators, and functions. It provides examples of Python syntax for writing and executing code as well as built-in data types like strings, integers, and lists. Key concepts covered include variables, data type casting, comments, arithmetic and comparison operators, and functions.
Introduction to Python for Data Science and Machine Learning ParrotAI
This document provides an introduction and overview of Python for data science and machine learning. It covers basics of Python including what Python is, its features, why it is useful for data science. It also discusses installing Python, using the IDLE and Jupyter Notebook environments. The document then covers Python basics like variables, data types, operators, decision making and loops. Finally, it discusses collection data types like lists, tuples and dictionaries and functions in Python.
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.
This document provides a high-level summary of an introduction to Python programming course. The summary includes an overview of Python basics like variables, data types, operators, conditionals, loops, functions and file handling. It also discusses commonly used Python libraries and concepts in data analytics like NumPy, Pandas, Matplotlib and statistics.
This document provides an overview and introduction to Python programming. It discusses Python basics like variables, data types, operators, conditionals, loops, functions and file handling. It also covers commonly used Python libraries and concepts in data analytics like NumPy, Pandas, Matplotlib and statistics. The document is intended as a whistle-stop tour to cover the most common aspects of Python.
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 ?
Maximizing Business Value with AWS Consulting Services.pdfElena Mia
An overview of how AWS consulting services empower organizations to optimize cloud adoption, enhance security, and drive innovation. Read More: https://www.damcogroup.com/aws-cloud-services/aws-consulting.
Bonk coin airdrop_ Everything You Need to Know.pdfHerond Labs
The Bonk airdrop, one of the largest in Solana’s history, distributed 50% of its total supply to community members, significantly boosting its popularity and Solana’s network activity. Below is everything you need to know about the Bonk coin airdrop, including its history, eligibility, how to claim tokens, risks, and current status.
https://blog.herond.org/bonk-coin-airdrop/
Insurance policy management software transforms complex, manual insurance operations into streamlined, efficient digital workflows, enhancing productivity, accuracy, customer service, and profitability for insurers. Visit https://www.damcogroup.com/insurance/policy-management-software for more details!
Revolutionize Your Insurance Workflow with Claims Management SoftwareInsurance Tech Services
Claims management software enhances efficiency, accuracy, and satisfaction by automating processes, reducing errors, and speeding up transparent claims handling—building trust and cutting costs. Explore More - https://www.damcogroup.com/insurance/claims-management-software
Who will create the languages of the future?Jordi Cabot
Will future languages be created by language engineers?
Can you "vibe" a DSL?
In this talk, we will explore the changing landscape of language engineering and discuss how Artificial Intelligence and low-code/no-code techniques can play a role in this future by helping in the definition, use, execution, and testing of new languages. Even empowering non-tech users to create their own language infrastructure. Maybe without them even realizing.
In this session we cover the benefits of a migration to Cosmos DB, migration paths, common pain points and best practices. We share our firsthand experiences and customer stories. Adiom is the trusted partner for migration solutions that enable seamless online database migrations from MongoDB to Cosmos DB vCore, and DynamoDB to Cosmos DB for NoSQL.
NTRODUCTION TO SOFTWARE TESTING
• Definition:
• Software testing is the process of evaluating and
verifying that a software application or system meets
specified requirements and functions correctly.
• Purpose:
• Identify defects and bugs in the software.
• Ensure the software meets quality standards.
• Validate that the software performs as intended in
various scenarios.
• Importance:
• Reduces risks associated with software failures.
• Improves user satisfaction and trust in the product.
• Enhances the overall reliability and performance of
the software
FME as an Orchestration Tool - Peak of Data & AI 2025Safe Software
Processing huge amounts of data through FME can have performance consequences, but as an orchestration tool, FME is brilliant! We'll take a look at the principles of data gravity, best practices, pros, cons, tips and tricks. And of course all spiced up with relevant examples!
Providing Better Biodiversity Through Better DataSafe Software
This session explores how FME is transforming data workflows at Ireland’s National Biodiversity Data Centre (NBDC) by eliminating manual data manipulation, incorporating machine learning, and enhancing overall efficiency. Attendees will gain insight into how NBDC is using FME to document and understand internal processes, make decision-making fully transparent, and shine a light on underlying code to improve clarity and reduce silent failures.
The presentation will also outline NBDC’s future plans for FME, including empowering staff to access and query data independently, without relying on external consultants. It will also showcase ambitions to connect to new data sources, unlock the full potential of its valuable datasets, create living atlases, and place its valuable data directly into the hands of decision-makers across Ireland—ensuring that biodiversity is not only protected but actively enhanced.
How Insurance Policy Administration Streamlines Policy Lifecycle for Agile Op...Insurance Tech Services
A modern Policy Administration System streamlines workflows and integrates with core systems to boost speed, accuracy, and customer satisfaction across the policy lifecycle. Visit https://www.damcogroup.com/insurance/policy-administration-systems for more details!
Join the Denver Marketo User Group, Captello and Integrate as we dive into the best practices, tools, and strategies for maintaining robust, high-performing databases. From managing vendors and automating orchestrations to enriching data for better insights, this session will unpack the key elements that keep your data ecosystem running smoothly—and smartly.
We will hear from Steve Armenti, Twelfth, and Aaron Karpaty, Captello, and Frannie Danzinger, Integrate.
Artificial Intelligence Applications Across IndustriesSandeepKS52
Artificial Intelligence is a rapidly growing field that influences many aspects of modern life, including transportation, healthcare, and finance. Understanding the basics of AI provides insight into how machines can learn and make decisions, which is essential for grasping its applications in various industries. In the automotive sector, AI enhances vehicle safety and efficiency through advanced technologies like self-driving systems and predictive maintenance. Similarly, in healthcare, AI plays a crucial role in diagnosing diseases and personalizing treatment plans, while in financial services, it helps in fraud detection and risk management. By exploring these themes, a clearer picture of AI's transformative impact on society emerges, highlighting both its potential benefits and challenges.
In a tight labor market and tighter economy, PMOs and resource managers must ensure that every team member is focused on the highest-value work. This session explores how AI reshapes resource planning and empowers organizations to forecast capacity, prevent burnout, and balance workloads more effectively, even with shrinking teams.
Code and No-Code Journeys: The Coverage OverlookApplitools
Explore practical ways to expand visual and functional UI coverage without deep coding or heavy maintenance in this session. Session recording and more info at applitools.com
Plooma is a writing platform to plan, write, and shape books your wayPlooma
Plooma is your all in one writing companion, designed to support authors at every twist and turn of the book creation journey. Whether you're sketching out your story's blueprint, breathing life into characters, or crafting chapters, Plooma provides a seamless space to organize all your ideas and materials without the overwhelm. Its intuitive interface makes building rich narratives and immersive worlds feel effortless.
Packed with powerful story and character organization tools, Plooma lets you track character development and manage world building details with ease. When it’s time to write, the distraction-free mode offers a clean, minimal environment to help you dive deep and write consistently. Plus, built-in editing tools catch grammar slips and style quirks in real-time, polishing your story so you don’t have to juggle multiple apps.
What really sets Plooma apart is its smart AI assistant - analyzing chapters for continuity, helping you generate character portraits, and flagging inconsistencies to keep your story tight and cohesive. This clever support saves you time and builds confidence, especially during those complex, detail packed projects.
Getting started is simple: outline your story’s structure and key characters with Plooma’s user-friendly planning tools, then write your chapters in the focused editor, using analytics to shape your words. Throughout your journey, Plooma’s AI offers helpful feedback and suggestions, guiding you toward a polished, well-crafted book ready to share with the world.
With Plooma by your side, you get a powerful toolkit that simplifies the creative process, boosts your productivity, and elevates your writing - making the path from idea to finished book smoother, more fun, and totally doable.
Get Started here: https://www.plooma.ink/
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