SlideShare a Scribd company logo
Python Programming
UNIT 1 : SYLLABUS
• Conceptual introduction: topics in computer science, algorithms;
• Modern computer systems: hardware architecture, data
representation in computers, software and operating system;
• Installing Python; basic syntax, interactive shell, editing, saving, and
running a script.
• The concept of data types; variables, assignments; immutable
variables; numerical types;
• arithmetic operators and expressions; comments in the program;
understanding error messages;
Expressions
Operators
Error Messages
Comments
ARITHMETIC
BITWISE
MEMBERSHI
P
IDENTITY
LOGICAL
COMPARISION
ASSIGNMENT
Operators
Operators
Arithmetic operators: EXPRESSION RESULT
10 + 20 30
40 - 15 25
15 * 10 150
25 / 5 5.0
5 ** 2 25
15 % 2 1
9 // 2 4
9.0 // 2.0 4.0
-11 // 3 - 4
-11.0 // 3 - 4.0
OPERATOR MEANING
+ Addition
- Subtraction
* Multiplication
/ Division
** Exponent
% Modulus
// Floor Division
Operators
Assignment operators:
• There are two types of assignment
statements in Python. They are:
1. Basic assignment statements
2. Augmented assignment
statements
• The simple syntax for a basic
assignment statement is:
variable_name = expression
• Ex :
a = 2 +3
a = a + 2
Operators
• There are two types of assignment
statements in Python. They are:
1. Basic assignment statements
2. Augmented assignment
statements
• We can combine arithmetic operators
in assignments to form an augmented
assignment statement.
a = a + b is written as a + = b
• Here the left-hand side i.e., a is
evaluated first, then value of b is
evaluated and then addition is
performed, and finally the addition
result is written back to a
x = x * 2 is written as x * = 2
Operators
OPERATOR EXAMPLE SAME AS
= X = 5 X = 5
+= X + = 3 X = X + 3
-+ X - = 3 X = X – 3
*= X * = 3 X = X * 3
/= X / = 3 X = X / 3
%= X % = 3 X = X % 3
//= X //= 3 X = X // 3
**= X ** = 3 X = X ** 3
Operators
Comparison operators:
• Comparison operators are used to
compare two values:
EX:
X = 3, Y = 4, Z = 4
X == Y Output: False
Y == Z Output: True
OPERATOR MEANING EXAMPLE
== Equal X == Y
!= Not Equal X != Y
> Greater than X > Y
< Less Than X < Y
>=
Greater than
or Equal to
X > = Y
<=
Less Than
or Equal to
X < =Y
Operators
Logical operators:
• Logical operators are used to combine conditional statements:
OPERATOR DESCRIPTION EXAMPLE
and
Returns True if both statements are
true
x < 5 and x < 10
or
Returns True if one of the
statements is true
x < 5 or x < 4
not
Reverse the result, returns False if
the result is true
not(x < 5 and x < 10)
Operators
Identity operators:
• Identity operators are used to compare the objects, not if they are equal,
but if they are the same object, with the same memory location:
OPERATOR DESCRIPTION EXAMPLE
is
Returns True if both variables are
the same object
x is y
is not
Returns True if both variables are
not the same object
x is not y
Operators
Membership operators:
• Membership operators are used to test if a sequence is presented in an
object:
OPERATOR DESCRIPTION EXAMPLE
in
Returns True if a sequence with the
specified value is present in the object
x in y
not in
Returns True if a sequence with the
specified value is not present in the object
x not in y
Operators
Bitwise operators:
• Bitwise operators
are used to compare
(binary) numbers:
OPERATOR MEANING DESCRIPTION
& AND Sets each bit to 1 if both bits are 1
| OR
Sets each bit to 1 if one of two
bits is 1
^ XOR
Sets each bit to 1 if only one of
two bits is 1
- NOT Inverts all the bits
<< Zero fill left shift
Shift left by pushing zeros in from
the right and let the leftmost bits
fall off
>>
Signed right
shift
Shift right by pushing copies of
the leftmost bit in from the left,
and let the rightmost bits fall off
ARITHMETIC
BITWISE
MEMBERSHI
P
IDENTITY
LOGICAL
COMPARISION
ASSIGNMENT
Operators
Expressions
Operators
Error Messages
Comments
Expressions
• An expression is a combination of
values(Constants), variables and
operators.
• Instructions that a Python
interpreter can execute are called
statements. For example, a = 1 is
an assignment statement.
• a = 10 # This is an assignment
statement
• b = 10 # This is an assignment
statement
• print(a + b)
o # a + b is an expression
o print(a + b) is a statement
• a = b * 5 + c
o # b * 5 + c is an expression
o a = b * 5 + c is a statement
Consider a=1, b=5, c=6, d=3.
Evaluate b – a * c / d + 10 Answer : 13
Expressions
Expressions
Operators
Error Messages
Comments
Comments
• A comment is a piece of program text that
the computer ignores but that provides
useful documentation to programmers.
• # symbol is used to add comments.
a = 10 # a value assigned
b = 20 # b value assigned
c = a + b # sum of a and b assigned to
c
Expressions
Operators
Error Messages
Comments
Error Messages
How Python Works:
• In python there are three types of errors;
o Syntax errors
o Semantic errors
o Exceptions
Error Messages
• The most common reason of an error in
a Python program is when a certain
statement is not in accordance with the
prescribed usage. Such an error is called
a syntax error.
• When Python encounters a syntax error
in a program, it halts execution with an
error message.
Error Messages
• A semantic error is detected when the
action that an expression describes
cannot be carried out, even though that
expression is syntactically correct.
Expressions
Operators
Error Messages
Comments
UNIT 1 : SYLLABUS
• Conceptual introduction: topics in computer science, algorithms;
• Modern computer systems: hardware architecture, data
representation in computers, software and operating system;
• Installing Python; basic syntax, interactive shell, editing, saving, and
running a script.
• The concept of data types; variables, assignments; immutable
variables; numerical types;
• arithmetic operators and expressions; comments in the program;
understanding error messages;

More Related Content

ODP
Operators
PPTX
Operator.ppt
PDF
Operators in python
PPTX
Precedence and associativity (Computer programming and utilization)
PPTX
C Operators
PPT
03 Operators and expressions
PPTX
Oop using JAVA
Operators
Operator.ppt
Operators in python
Precedence and associativity (Computer programming and utilization)
C Operators
03 Operators and expressions
Oop using JAVA

What's hot (19)

PPTX
COM1407: C Operators
PPTX
Python operators
PPTX
Python Training in Bangalore | Python Operators | Learnbay.in
PPTX
Python operators
PPTX
Operators in Python
PPTX
Operator Precedence and Associativity
DOC
Report on c
PDF
Operators in python
PDF
Operators in c programming
PPT
CBSE Class XI :- Operators in C++
PPTX
Python Operators
PPT
Operators
PPTX
Operators in python
PDF
Python : basic operators
PPT
C Prog. - Operators and Expressions
PPTX
What are operators?
PPT
Arithmetic operator
PDF
Python Basic Operators
COM1407: C Operators
Python operators
Python Training in Bangalore | Python Operators | Learnbay.in
Python operators
Operators in Python
Operator Precedence and Associativity
Report on c
Operators in python
Operators in c programming
CBSE Class XI :- Operators in C++
Python Operators
Operators
Operators in python
Python : basic operators
C Prog. - Operators and Expressions
What are operators?
Arithmetic operator
Python Basic Operators
Ad

Similar to Python Programming | JNTUK | UNIT 1 | Lecture 5 (20)

PPTX
Python programming language introduction unit
PPTX
operatorsinpython-18112209560412 (1).pptx
PPTX
Operators Concept in Python-N.Kavitha.pptx
PPTX
Different Types of Operators in Python.pptx
PPTX
Operators in Python Arithmetic Operators
PPTX
python statement, expressions and operators.pptx
PDF
Operators_in_Python_Simplified_languages
PPTX
Python Lec-6 Operatorguijjjjuugggggs.pptx
PPTX
python operators.pptx
PPTX
Python second ppt
PPTX
OPERATORS-PYTHON.pptx ALL OPERATORS ARITHMATIC AND LOGICAL
PPTX
PYTHON OPERATORS 123Python Operators.pptx
PPTX
Understanding All Types of Operators in Python with Examples"
PPTX
Data Handling
PPTX
Python assignment 1 Biswajit Mohapatra.pptx
PPT
hlukj6;lukm,t.mnjhgjukryopkiu;lyk y2.ppt
PPT
Py-Slides-2 (1).ppt
PPT
Py-Slides-2.ppt
PPT
Py-Slides-2.ppt
Python programming language introduction unit
operatorsinpython-18112209560412 (1).pptx
Operators Concept in Python-N.Kavitha.pptx
Different Types of Operators in Python.pptx
Operators in Python Arithmetic Operators
python statement, expressions and operators.pptx
Operators_in_Python_Simplified_languages
Python Lec-6 Operatorguijjjjuugggggs.pptx
python operators.pptx
Python second ppt
OPERATORS-PYTHON.pptx ALL OPERATORS ARITHMATIC AND LOGICAL
PYTHON OPERATORS 123Python Operators.pptx
Understanding All Types of Operators in Python with Examples"
Data Handling
Python assignment 1 Biswajit Mohapatra.pptx
hlukj6;lukm,t.mnjhgjukryopkiu;lyk y2.ppt
Py-Slides-2 (1).ppt
Py-Slides-2.ppt
Py-Slides-2.ppt
Ad

More from FabMinds (20)

PPTX
Python Programming | JNTUA | UNIT 3 | Lists |
PPTX
Python Programming | JNTUA | UNIT 3 | Strings |
PPTX
Python Programming | JNTUA | UNIT 3 | Updating Variables & Iteration |
PPTX
Python Programming | JNTUA | UNIT 2 | Case Study |
PPTX
Python Programming | JNTUA | UNIT 2 | Fruitful Functions |
PPTX
Python Programming | JNTUA | UNIT 2 | Conditionals and Recursion |
PPTX
Application layer protocols
PPTX
Internet connectivity
PPTX
Introduction for internet connectivity (IoT)
PPTX
web connectivity in IoT
PPTX
message communication protocols in IoT
PPTX
web communication protocols in IoT
PPTX
introduction for web connectivity (IoT)
PPTX
Python Introduction | JNTUA | R19 | UNIT 1 | Functions
PPTX
Python Introduction | JNTUA | R19 | UNIT 1 | Functions
PPTX
Python Programming | JNTUK | UNIT 2 | Lecture 6 & 7 | Conditional & Control S...
PPTX
Data enrichment
PPTX
Communication technologies
PPTX
M2M systems layers and designs standardizations
PPTX
Business models for business processes on IoT
Python Programming | JNTUA | UNIT 3 | Lists |
Python Programming | JNTUA | UNIT 3 | Strings |
Python Programming | JNTUA | UNIT 3 | Updating Variables & Iteration |
Python Programming | JNTUA | UNIT 2 | Case Study |
Python Programming | JNTUA | UNIT 2 | Fruitful Functions |
Python Programming | JNTUA | UNIT 2 | Conditionals and Recursion |
Application layer protocols
Internet connectivity
Introduction for internet connectivity (IoT)
web connectivity in IoT
message communication protocols in IoT
web communication protocols in IoT
introduction for web connectivity (IoT)
Python Introduction | JNTUA | R19 | UNIT 1 | Functions
Python Introduction | JNTUA | R19 | UNIT 1 | Functions
Python Programming | JNTUK | UNIT 2 | Lecture 6 & 7 | Conditional & Control S...
Data enrichment
Communication technologies
M2M systems layers and designs standardizations
Business models for business processes on IoT

Recently uploaded (20)

PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
01-Introduction-to-Information-Management.pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PPTX
master seminar digital applications in india
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PDF
Business Ethics Teaching Materials for college
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
Microbial disease of the cardiovascular and lymphatic systems
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
STATICS OF THE RIGID BODIES Hibbelers.pdf
01-Introduction-to-Information-Management.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Final Presentation General Medicine 03-08-2024.pptx
PPH.pptx obstetrics and gynecology in nursing
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
master seminar digital applications in india
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Week 4 Term 3 Study Techniques revisited.pptx
Business Ethics Teaching Materials for college
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Microbial diseases, their pathogenesis and prophylaxis
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Anesthesia in Laparoscopic Surgery in India
Abdominal Access Techniques with Prof. Dr. R K Mishra
Module 4: Burden of Disease Tutorial Slides S2 2025

Python Programming | JNTUK | UNIT 1 | Lecture 5

  • 2. UNIT 1 : SYLLABUS • Conceptual introduction: topics in computer science, algorithms; • Modern computer systems: hardware architecture, data representation in computers, software and operating system; • Installing Python; basic syntax, interactive shell, editing, saving, and running a script. • The concept of data types; variables, assignments; immutable variables; numerical types; • arithmetic operators and expressions; comments in the program; understanding error messages;
  • 5. Operators Arithmetic operators: EXPRESSION RESULT 10 + 20 30 40 - 15 25 15 * 10 150 25 / 5 5.0 5 ** 2 25 15 % 2 1 9 // 2 4 9.0 // 2.0 4.0 -11 // 3 - 4 -11.0 // 3 - 4.0 OPERATOR MEANING + Addition - Subtraction * Multiplication / Division ** Exponent % Modulus // Floor Division
  • 6. Operators Assignment operators: • There are two types of assignment statements in Python. They are: 1. Basic assignment statements 2. Augmented assignment statements • The simple syntax for a basic assignment statement is: variable_name = expression • Ex : a = 2 +3 a = a + 2
  • 7. Operators • There are two types of assignment statements in Python. They are: 1. Basic assignment statements 2. Augmented assignment statements • We can combine arithmetic operators in assignments to form an augmented assignment statement. a = a + b is written as a + = b • Here the left-hand side i.e., a is evaluated first, then value of b is evaluated and then addition is performed, and finally the addition result is written back to a x = x * 2 is written as x * = 2
  • 8. Operators OPERATOR EXAMPLE SAME AS = X = 5 X = 5 += X + = 3 X = X + 3 -+ X - = 3 X = X – 3 *= X * = 3 X = X * 3 /= X / = 3 X = X / 3 %= X % = 3 X = X % 3 //= X //= 3 X = X // 3 **= X ** = 3 X = X ** 3
  • 9. Operators Comparison operators: • Comparison operators are used to compare two values: EX: X = 3, Y = 4, Z = 4 X == Y Output: False Y == Z Output: True OPERATOR MEANING EXAMPLE == Equal X == Y != Not Equal X != Y > Greater than X > Y < Less Than X < Y >= Greater than or Equal to X > = Y <= Less Than or Equal to X < =Y
  • 10. Operators Logical operators: • Logical operators are used to combine conditional statements: OPERATOR DESCRIPTION EXAMPLE and Returns True if both statements are true x < 5 and x < 10 or Returns True if one of the statements is true x < 5 or x < 4 not Reverse the result, returns False if the result is true not(x < 5 and x < 10)
  • 11. Operators Identity operators: • Identity operators are used to compare the objects, not if they are equal, but if they are the same object, with the same memory location: OPERATOR DESCRIPTION EXAMPLE is Returns True if both variables are the same object x is y is not Returns True if both variables are not the same object x is not y
  • 12. Operators Membership operators: • Membership operators are used to test if a sequence is presented in an object: OPERATOR DESCRIPTION EXAMPLE in Returns True if a sequence with the specified value is present in the object x in y not in Returns True if a sequence with the specified value is not present in the object x not in y
  • 13. Operators Bitwise operators: • Bitwise operators are used to compare (binary) numbers: OPERATOR MEANING DESCRIPTION & AND Sets each bit to 1 if both bits are 1 | OR Sets each bit to 1 if one of two bits is 1 ^ XOR Sets each bit to 1 if only one of two bits is 1 - NOT Inverts all the bits << Zero fill left shift Shift left by pushing zeros in from the right and let the leftmost bits fall off >> Signed right shift Shift right by pushing copies of the leftmost bit in from the left, and let the rightmost bits fall off
  • 16. Expressions • An expression is a combination of values(Constants), variables and operators. • Instructions that a Python interpreter can execute are called statements. For example, a = 1 is an assignment statement. • a = 10 # This is an assignment statement • b = 10 # This is an assignment statement • print(a + b) o # a + b is an expression o print(a + b) is a statement • a = b * 5 + c o # b * 5 + c is an expression o a = b * 5 + c is a statement
  • 17. Consider a=1, b=5, c=6, d=3. Evaluate b – a * c / d + 10 Answer : 13
  • 20. Comments • A comment is a piece of program text that the computer ignores but that provides useful documentation to programmers. • # symbol is used to add comments. a = 10 # a value assigned b = 20 # b value assigned c = a + b # sum of a and b assigned to c
  • 22. Error Messages How Python Works: • In python there are three types of errors; o Syntax errors o Semantic errors o Exceptions
  • 23. Error Messages • The most common reason of an error in a Python program is when a certain statement is not in accordance with the prescribed usage. Such an error is called a syntax error. • When Python encounters a syntax error in a program, it halts execution with an error message.
  • 24. Error Messages • A semantic error is detected when the action that an expression describes cannot be carried out, even though that expression is syntactically correct.
  • 26. UNIT 1 : SYLLABUS • Conceptual introduction: topics in computer science, algorithms; • Modern computer systems: hardware architecture, data representation in computers, software and operating system; • Installing Python; basic syntax, interactive shell, editing, saving, and running a script. • The concept of data types; variables, assignments; immutable variables; numerical types; • arithmetic operators and expressions; comments in the program; understanding error messages;