SlideShare a Scribd company logo
Python Programming
UNIT 2 : SYLLABUS
• Conditions, Boolean logic, logical operators; (Refer UNIT 1: Operators)
• ranges
• Control statements: if-else, loops (for, while); short-circuit (lazy) evaluation
• Strings and text files; manipulating files and directories, os and sys
modules; text files: reading/writing text and numbers from/to a file;
creating and reading a formatted file (csv or tab-separated).
• String manipulations: subscript operator, indexing, slicing a string;
• strings and number system: converting strings to numbers and vice versa.
Binary, octal, hexadecimal numbers
range function
• The range() function returns a sequence of
numbers, starting from 0 by default, and
increments by 1 (by default), and stops
before a specified number
• The range() function can be represented in
three different ways, or you can think of
them as three range parameters:
1. range(stop)
2. range(start, stop)
3. range(start, stop, step)
• start: integer starting from which the
sequence of integers is to be returned
• stop: integer before which the
sequence of integers is to be returned.
The range of integers end at stop – 1.
• step: integer value which determines
the increment between each integer in
the sequence
range function
Strings and text files
Control statements
strings and number
system
String manipulations
Conditional (if – else)
Conditional
execution
Alternative
execution
Chained conditionals
Nested
conditionals
• Conditions
change the flow
of program
execution
• if statement is
used in conditions
Syntax:
if condition:
statement 1
…
• Two possibilities
(else is used)
Syntax:
if condition:
statement 1
…
else:
statement 2
…
• More than two
possibilities.
• elif is used.
Syntax:
if condition:
statement 1
elif condition:
statement 2
elif condition:
statement 3
else:
statement 4
• Another
Condition in one
condition
Syntax:
if condition1:
if condition2:
statement 1
else:
statement 2
else:
statement 3
Control
statements
Conditional (if – else)
Control
statements
Conditional
execution
• Conditions
change the flow
of program
execution
• if statement is
used in conditions
Syntax:
if condition:
statement 1
…
Conditional (if – else)
Control
statements
Conditional
execution
• Conditions
change the flow
of program
execution
• if statement is
used in conditions
Syntax:
if condition:
statement 1
…
Control
statements
Conditional
execution
Alternative
execution
Chained conditionals
Nested
conditionals
• Conditions
change the flow
of program
execution
• if statement is
used in conditions
Syntax:
if condition:
statement 1
…
• Two possibilities
(else is used)
Syntax:
if condition:
statement 1
…
else:
statement 2
…
• More than two
possibilities.
• elif is used.
Syntax:
if condition:
statement 1
elif condition:
statement 2
elif condition:
statement 3
else:
statement 4
• Another
Condition in one
condition
Syntax:
if condition1:
if condition2:
statement 1
else:
statement 2
else:
statement 3
Conditional (if – else)
Conditional (if – else)
Control
statements
Alternative
execution
• Two possibilities
(else is used)
Syntax:
if condition:
statement 1
…
else:
statement 2
…
Conditional (if – else)
Control
statements
Alternative
execution
• Two possibilities
(else is used)
Syntax:
if condition:
statement 1
…
else:
statement 2
…
Conditional (if – else)
Control
statements
Conditional
execution
Alternative
execution
Chained conditionals
Nested
conditionals
• Conditions
change the flow
of program
execution
• if statement is
used in conditions
Syntax:
if condition:
statement 1
…
• Two possibilities
(else is used)
Syntax:
if condition:
statement 1
…
else:
statement 2
…
• More than two
possibilities.
• elif is used.
Syntax:
if condition:
statement 1
elif condition:
statement 2
elif condition:
statement 3
else:
statement 4
• Another
Condition in one
condition
Syntax:
if condition1:
if condition2:
statement 1
else:
statement 2
else:
statement 3
Conditional (if – else)
Control
statements
Chained conditionals
• More than two
possibilities.
• elif is used.
Syntax:
if condition:
statement 1
elif condition:
statement 2
elif condition:
statement 3
else:
statement 4
Conditional (if – else)
Control
statements
Chained conditionals
• More than two
possibilities.
• elif is used.
Syntax:
if condition:
statement 1
elif condition:
statement 2
elif condition:
statement 3
else:
statement 4
Conditional (if – else)
Control
statements
Conditional
execution
Alternative
execution
Chained conditionals
Nested
conditionals
• Conditions
change the flow
of program
execution
• if statement is
used in conditions
Syntax:
if condition:
statement 1
…
• Two possibilities
(else is used)
Syntax:
if condition:
statement 1
…
else:
statement 2
…
• More than two
possibilities.
• elif is used.
Syntax:
if condition:
statement 1
elif condition:
statement 2
elif condition:
statement 3
else:
statement 4
• Another
Condition in one
condition
Syntax:
if condition1:
if condition2:
statement 1
else:
statement 2
else:
statement 3
Conditional (if – else)
Control
statements
Nested
conditionals
• Another
Condition in one
condition
Syntax:
if condition1:
if condition2:
statement 1
else:
statement 2
else:
statement 3
Conditional (if – else)
Control
statements
Nested
conditionals
• Another
Condition in one
condition
Syntax:
if condition1:
if condition2:
statement 1
else:
statement 2
else:
statement 3
Conditional (if – else)
Control
statements
Conditional
execution
Alternative
execution
Chained conditionals
Nested
conditionals
• Conditions
change the flow
of program
execution
• if statement is
used in conditions
Syntax:
if condition:
statement 1
…
• Two possibilities
(else is used)
Syntax:
if condition:
statement 1
…
else:
statement 2
…
• More than two
possibilities.
• elif is used.
Syntax:
if condition:
statement 1
elif condition:
statement 2
elif condition:
statement 3
else:
statement 4
• Another
Condition in one
condition
Syntax:
if condition1:
if condition2:
statement 1
else:
statement 2
else:
statement 3
Strings and text files
Control statements
strings and number
system
String manipulations
Loops (for , while)
Control
statements
• A loop is a programming
structure that repeats a sequence
of instructions until a specific
condition is met.
• Each repetition of the action is
known as a pass or an iteration.
• Two main loop statements are
available.
• for
• while
Loops (for , while)
Control
statements
• for: Executes a sequence of
statements multiple times and
reduces the code that manages the
loop variable.
Loops (for , while)
Control
statements
Loop Header end with colon (:)
body must be indented
Loops (for , while)
Control
statements
Loops (for , while)
Control
statements
Using else Statement with for
Loop:
• If the else statement is used with
a for loop, the else statement is
executed when the loop has
exhausted iterating the list.
Loops (for , while)
Control
statements
• A while loop statement in Python
programming language
repeatedly executes a target
statement if a given condition is
true.
Loops (for , while)
Control
statements
Loops (for , while)
Control
statements
Loops (for , while)
Control
statements
Using else Statement with while
Loop:
• If the else statement is used with
a while loop, the else statement is
executed when the condition
becomes false.
Loops (for , while)
Control
statements
Infinite Loop:
• A loop becomes infinite loop if a
condition never becomes FALSE.
• When using while loops because
of the possibility that this
condition never resolves to a
FALSE value.
• This results in a loop that never
ends. Such a loop is called an
infinite loop.
Loops (for , while)
Control
statements
Loop Control Statements:
• Loop control statements change
execution from its normal
sequence.
• Python supports the following
control statements.
o break
o continue
o pass
break: Terminates the loop statement
and transfers execution to the
statement immediately following the
loop.
continue: Causes the loop to skip the
remainder of its body and
immediately retest its condition prior
to reiterating.
pass: when a statement is required
syntactically but you do not want
any command or code to execute.
Loops (for , while)
Control
statements
break: Terminates the loop statement
and transfers execution to the
statement immediately following the
loop.
continue: Causes the loop to skip the
remainder of its body and
immediately retest its condition prior
to reiterating.
pass: when a statement is required
syntactically but you do not want
any command or code to execute.
Loops (for , while)
Control
statements
break: Terminates the loop statement
and transfers execution to the
statement immediately following the
loop.
continue: Causes the loop to skip the
remainder of its body and
immediately retest its condition prior
to reiterating.
pass: when a statement is required
syntactically but you do not want
any command or code to execute.
Loops (for , while)
Control
statements
break: Terminates the loop statement
and transfers execution to the
statement immediately following the
loop.
continue: Causes the loop to skip the
remainder of its body and
immediately retest its condition prior
to reiterating.
pass: when a statement is required
syntactically but you do not want
any command or code to execute.
Loops (for , while)
Control
statements
Loops (for , while)
Control
statements
Loops (for , while)
Control
statements
Loops (for , while)
Control
statements
Nested Loop:
• Python programming language
allows to use one loop inside
another loop.
Loops (for , while)
Control
statements
Nested Loop:
• Python programming language
allows to use one loop inside
another loop.
Strings and text files
Control statements
strings and number
system
String manipulations
Short-Circuit Evaluation
Control
statements
• The Python virtual machine
sometimes knows the value of a
Boolean expression before it has
evaluated all its operands.
• For instance, in the expression A
and B, if A is false, then so is the
expression, and there is no need to
evaluate B
• Likewise, in the expression A or B, if A
is true, then so is the expression, and
again there is no need to evaluate B.
• This approach, in which evaluation
stops as soon as possible, is called
short-circuit evaluation.
UNIT 2 : SYLLABUS
• Conditions, Boolean logic, logical operators; (Refer UNIT 1: Operators)
• ranges
• Control statements: if-else, loops (for, while); short-circuit (lazy) evaluation
• Strings and text files; manipulating files and directories, os and sys
modules; text files: reading/writing text and numbers from/to a file;
creating and reading a formatted file (csv or tab-separated).
• String manipulations: subscript operator, indexing, slicing a string;
• strings and number system: converting strings to numbers and vice versa.
Binary, octal, hexadecimal numbers

More Related Content

PPTX
Strings in Java
PPTX
Python OOPs
PPTX
Python Programming | JNTUA | UNIT 3 | Lists |
PPT
Python GUI Programming
PPTX
Class, object and inheritance in python
PPTX
Arrays in java
PPT
Working with frames
Strings in Java
Python OOPs
Python Programming | JNTUA | UNIT 3 | Lists |
Python GUI Programming
Class, object and inheritance in python
Arrays in java
Working with frames

What's hot (20)

PPTX
Python Programming | JNTUA | UNIT 2 | Conditionals and Recursion |
PDF
Python - object oriented
PPTX
Inline function
PPT
Unit 1 introduction to data structure
PPTX
Understanding java streams
PDF
Python programming : Classes objects
PDF
Function arguments In Python
PDF
Namespaces
PPTX
Basics of Object Oriented Programming in Python
PPT
9. Input Output in java
PPT
data structure
PPTX
Python Data Structures and Algorithms.pptx
PPTX
String, string builder, string buffer
PPTX
Files in Python.pptx
PDF
Arrays In Python | Python Array Operations | Edureka
PDF
PDF
Object oriented approach in python programming
PPTX
Modules in Python Programming
PPT
Oops in Java
Python Programming | JNTUA | UNIT 2 | Conditionals and Recursion |
Python - object oriented
Inline function
Unit 1 introduction to data structure
Understanding java streams
Python programming : Classes objects
Function arguments In Python
Namespaces
Basics of Object Oriented Programming in Python
9. Input Output in java
data structure
Python Data Structures and Algorithms.pptx
String, string builder, string buffer
Files in Python.pptx
Arrays In Python | Python Array Operations | Edureka
Object oriented approach in python programming
Modules in Python Programming
Oops in Java
Ad

Similar to Python Programming | JNTUK | UNIT 2 | Lecture 6 & 7 | Conditional & Control Statements (20)

PPT
8 statement level
PPTX
C language (Part 2)
PPTX
pds first unit module 2 MODULE FOR ppt.pptx
PPTX
Module_2_1_Building Python Programs_Final.pptx
PPTX
chapter 6.pptx
PPT
control-statements....ppt - definition
PPTX
DECISION MAKING AND BRANCHING - C Programming
PPTX
Programming Fundamentals in C++ structures
PPSX
class interview demo
PPTX
PPTX
Demo for Class.pptx
PPT
Lecture-13.ppt
PPTX
Python Introduction controll structures and conprehansion
PDF
Control statements anil
PPTX
Operators loops conditional and statements
PPT
Control structures repetition
PPT
C++ chapter 4
PPTX
Week 4.pptx computational thinking and programming
PPT
Lecture on Control Structures - For, while, do while loop
8 statement level
C language (Part 2)
pds first unit module 2 MODULE FOR ppt.pptx
Module_2_1_Building Python Programs_Final.pptx
chapter 6.pptx
control-statements....ppt - definition
DECISION MAKING AND BRANCHING - C Programming
Programming Fundamentals in C++ structures
class interview demo
Demo for Class.pptx
Lecture-13.ppt
Python Introduction controll structures and conprehansion
Control statements anil
Operators loops conditional and statements
Control structures repetition
C++ chapter 4
Week 4.pptx computational thinking and programming
Lecture on Control Structures - For, while, do while loop
Ad

More from FabMinds (20)

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
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
Data enrichment
PPTX
Communication technologies
PPTX
M2M systems layers and designs standardizations
PPTX
Business models for business processes on IoT
PPTX
Python Programming | JNTUK | UNIT 1 | Lecture 5
PPTX
Python Programming | JNTUK | UNIT 1 | Lecture 4
PPTX
Python Programming | JNTUK | UNIT 1 | Lecture 1 & 2
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 |
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
Data enrichment
Communication technologies
M2M systems layers and designs standardizations
Business models for business processes on IoT
Python Programming | JNTUK | UNIT 1 | Lecture 5
Python Programming | JNTUK | UNIT 1 | Lecture 4
Python Programming | JNTUK | UNIT 1 | Lecture 1 & 2

Recently uploaded (20)

PDF
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
English Language Teaching from Post-.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
The Final Stretch: How to Release a Game and Not Die in the Process.
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Insiders guide to clinical Medicine.pdf
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PPTX
Onica Farming 24rsclub profitable farm business
PDF
01-Introduction-to-Information-Management.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Abdominal Access Techniques with Prof. Dr. R K Mishra
FourierSeries-QuestionsWithAnswers(Part-A).pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
NOI Hackathon - Summer Edition - GreenThumber.pptx
O5-L3 Freight Transport Ops (International) V1.pdf
English Language Teaching from Post-.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Week 4 Term 3 Study Techniques revisited.pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
The Final Stretch: How to Release a Game and Not Die in the Process.
TR - Agricultural Crops Production NC III.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Insiders guide to clinical Medicine.pdf
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Onica Farming 24rsclub profitable farm business
01-Introduction-to-Information-Management.pdf
O7-L3 Supply Chain Operations - ICLT Program

Python Programming | JNTUK | UNIT 2 | Lecture 6 & 7 | Conditional & Control Statements

  • 2. UNIT 2 : SYLLABUS • Conditions, Boolean logic, logical operators; (Refer UNIT 1: Operators) • ranges • Control statements: if-else, loops (for, while); short-circuit (lazy) evaluation • Strings and text files; manipulating files and directories, os and sys modules; text files: reading/writing text and numbers from/to a file; creating and reading a formatted file (csv or tab-separated). • String manipulations: subscript operator, indexing, slicing a string; • strings and number system: converting strings to numbers and vice versa. Binary, octal, hexadecimal numbers
  • 3. range function • The range() function returns a sequence of numbers, starting from 0 by default, and increments by 1 (by default), and stops before a specified number • The range() function can be represented in three different ways, or you can think of them as three range parameters: 1. range(stop) 2. range(start, stop) 3. range(start, stop, step) • start: integer starting from which the sequence of integers is to be returned • stop: integer before which the sequence of integers is to be returned. The range of integers end at stop – 1. • step: integer value which determines the increment between each integer in the sequence
  • 5. Strings and text files Control statements strings and number system String manipulations
  • 6. Conditional (if – else) Conditional execution Alternative execution Chained conditionals Nested conditionals • Conditions change the flow of program execution • if statement is used in conditions Syntax: if condition: statement 1 … • Two possibilities (else is used) Syntax: if condition: statement 1 … else: statement 2 … • More than two possibilities. • elif is used. Syntax: if condition: statement 1 elif condition: statement 2 elif condition: statement 3 else: statement 4 • Another Condition in one condition Syntax: if condition1: if condition2: statement 1 else: statement 2 else: statement 3 Control statements
  • 7. Conditional (if – else) Control statements Conditional execution • Conditions change the flow of program execution • if statement is used in conditions Syntax: if condition: statement 1 …
  • 8. Conditional (if – else) Control statements Conditional execution • Conditions change the flow of program execution • if statement is used in conditions Syntax: if condition: statement 1 …
  • 9. Control statements Conditional execution Alternative execution Chained conditionals Nested conditionals • Conditions change the flow of program execution • if statement is used in conditions Syntax: if condition: statement 1 … • Two possibilities (else is used) Syntax: if condition: statement 1 … else: statement 2 … • More than two possibilities. • elif is used. Syntax: if condition: statement 1 elif condition: statement 2 elif condition: statement 3 else: statement 4 • Another Condition in one condition Syntax: if condition1: if condition2: statement 1 else: statement 2 else: statement 3 Conditional (if – else)
  • 10. Conditional (if – else) Control statements Alternative execution • Two possibilities (else is used) Syntax: if condition: statement 1 … else: statement 2 …
  • 11. Conditional (if – else) Control statements Alternative execution • Two possibilities (else is used) Syntax: if condition: statement 1 … else: statement 2 …
  • 12. Conditional (if – else) Control statements Conditional execution Alternative execution Chained conditionals Nested conditionals • Conditions change the flow of program execution • if statement is used in conditions Syntax: if condition: statement 1 … • Two possibilities (else is used) Syntax: if condition: statement 1 … else: statement 2 … • More than two possibilities. • elif is used. Syntax: if condition: statement 1 elif condition: statement 2 elif condition: statement 3 else: statement 4 • Another Condition in one condition Syntax: if condition1: if condition2: statement 1 else: statement 2 else: statement 3
  • 13. Conditional (if – else) Control statements Chained conditionals • More than two possibilities. • elif is used. Syntax: if condition: statement 1 elif condition: statement 2 elif condition: statement 3 else: statement 4
  • 14. Conditional (if – else) Control statements Chained conditionals • More than two possibilities. • elif is used. Syntax: if condition: statement 1 elif condition: statement 2 elif condition: statement 3 else: statement 4
  • 15. Conditional (if – else) Control statements Conditional execution Alternative execution Chained conditionals Nested conditionals • Conditions change the flow of program execution • if statement is used in conditions Syntax: if condition: statement 1 … • Two possibilities (else is used) Syntax: if condition: statement 1 … else: statement 2 … • More than two possibilities. • elif is used. Syntax: if condition: statement 1 elif condition: statement 2 elif condition: statement 3 else: statement 4 • Another Condition in one condition Syntax: if condition1: if condition2: statement 1 else: statement 2 else: statement 3
  • 16. Conditional (if – else) Control statements Nested conditionals • Another Condition in one condition Syntax: if condition1: if condition2: statement 1 else: statement 2 else: statement 3
  • 17. Conditional (if – else) Control statements Nested conditionals • Another Condition in one condition Syntax: if condition1: if condition2: statement 1 else: statement 2 else: statement 3
  • 18. Conditional (if – else) Control statements Conditional execution Alternative execution Chained conditionals Nested conditionals • Conditions change the flow of program execution • if statement is used in conditions Syntax: if condition: statement 1 … • Two possibilities (else is used) Syntax: if condition: statement 1 … else: statement 2 … • More than two possibilities. • elif is used. Syntax: if condition: statement 1 elif condition: statement 2 elif condition: statement 3 else: statement 4 • Another Condition in one condition Syntax: if condition1: if condition2: statement 1 else: statement 2 else: statement 3
  • 19. Strings and text files Control statements strings and number system String manipulations
  • 20. Loops (for , while) Control statements • A loop is a programming structure that repeats a sequence of instructions until a specific condition is met. • Each repetition of the action is known as a pass or an iteration. • Two main loop statements are available. • for • while
  • 21. Loops (for , while) Control statements • for: Executes a sequence of statements multiple times and reduces the code that manages the loop variable.
  • 22. Loops (for , while) Control statements Loop Header end with colon (:) body must be indented
  • 23. Loops (for , while) Control statements
  • 24. Loops (for , while) Control statements Using else Statement with for Loop: • If the else statement is used with a for loop, the else statement is executed when the loop has exhausted iterating the list.
  • 25. Loops (for , while) Control statements • A while loop statement in Python programming language repeatedly executes a target statement if a given condition is true.
  • 26. Loops (for , while) Control statements
  • 27. Loops (for , while) Control statements
  • 28. Loops (for , while) Control statements Using else Statement with while Loop: • If the else statement is used with a while loop, the else statement is executed when the condition becomes false.
  • 29. Loops (for , while) Control statements Infinite Loop: • A loop becomes infinite loop if a condition never becomes FALSE. • When using while loops because of the possibility that this condition never resolves to a FALSE value. • This results in a loop that never ends. Such a loop is called an infinite loop.
  • 30. Loops (for , while) Control statements Loop Control Statements: • Loop control statements change execution from its normal sequence. • Python supports the following control statements. o break o continue o pass break: Terminates the loop statement and transfers execution to the statement immediately following the loop. continue: Causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating. pass: when a statement is required syntactically but you do not want any command or code to execute.
  • 31. Loops (for , while) Control statements break: Terminates the loop statement and transfers execution to the statement immediately following the loop. continue: Causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating. pass: when a statement is required syntactically but you do not want any command or code to execute.
  • 32. Loops (for , while) Control statements break: Terminates the loop statement and transfers execution to the statement immediately following the loop. continue: Causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating. pass: when a statement is required syntactically but you do not want any command or code to execute.
  • 33. Loops (for , while) Control statements break: Terminates the loop statement and transfers execution to the statement immediately following the loop. continue: Causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating. pass: when a statement is required syntactically but you do not want any command or code to execute.
  • 34. Loops (for , while) Control statements
  • 35. Loops (for , while) Control statements
  • 36. Loops (for , while) Control statements
  • 37. Loops (for , while) Control statements Nested Loop: • Python programming language allows to use one loop inside another loop.
  • 38. Loops (for , while) Control statements Nested Loop: • Python programming language allows to use one loop inside another loop.
  • 39. Strings and text files Control statements strings and number system String manipulations
  • 40. Short-Circuit Evaluation Control statements • The Python virtual machine sometimes knows the value of a Boolean expression before it has evaluated all its operands. • For instance, in the expression A and B, if A is false, then so is the expression, and there is no need to evaluate B • Likewise, in the expression A or B, if A is true, then so is the expression, and again there is no need to evaluate B. • This approach, in which evaluation stops as soon as possible, is called short-circuit evaluation.
  • 41. UNIT 2 : SYLLABUS • Conditions, Boolean logic, logical operators; (Refer UNIT 1: Operators) • ranges • Control statements: if-else, loops (for, while); short-circuit (lazy) evaluation • Strings and text files; manipulating files and directories, os and sys modules; text files: reading/writing text and numbers from/to a file; creating and reading a formatted file (csv or tab-separated). • String manipulations: subscript operator, indexing, slicing a string; • strings and number system: converting strings to numbers and vice versa. Binary, octal, hexadecimal numbers