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
Python Programming | JNTUA | UNIT 2 | Conditionals and Recursion |
PPTX
Functions in Python
PPSX
python Function
PPT
Chapter 5 -Syntax Directed Translation - Copy.ppt
PPTX
Python Programming | JNTUA | UNIT 3 | Lists |
PPTX
Artificial Intelligence- TicTacToe game
PPT
Classical problem of synchronization
Python Programming | JNTUA | UNIT 2 | Conditionals and Recursion |
Functions in Python
python Function
Chapter 5 -Syntax Directed Translation - Copy.ppt
Python Programming | JNTUA | UNIT 3 | Lists |
Artificial Intelligence- TicTacToe game
Classical problem of synchronization

What's hot (20)

PPT
Asymptotic notations
PPTX
Code generation
PPTX
Types of Statements in Python Programming Language
PDF
Python basic
PDF
Data Structures Chapter-2
PPT
Multi Head, Multi Tape Turing Machine
PPTX
PPTX
Fuzzy rules and fuzzy reasoning
PPTX
Petri Nets: Properties, Analysis and Applications
PPTX
Data reduction
PDF
Functions and modules in python
PPT
Omega example
PDF
Python NumPy Tutorial | NumPy Array | Edureka
PDF
Operators in python
PPTX
Logics for non monotonic reasoning-ai
PDF
Numeric Data types in Python
PDF
Rules of inference
PPTX
Simple if else statement,nesting of if else statement & else if ladder
PDF
Introduction to python programming
Asymptotic notations
Code generation
Types of Statements in Python Programming Language
Python basic
Data Structures Chapter-2
Multi Head, Multi Tape Turing Machine
Fuzzy rules and fuzzy reasoning
Petri Nets: Properties, Analysis and Applications
Data reduction
Functions and modules in python
Omega example
Python NumPy Tutorial | NumPy Array | Edureka
Operators in python
Logics for non monotonic reasoning-ai
Numeric Data types in Python
Rules of inference
Simple if else statement,nesting of if else statement & else if ladder
Introduction to python programming
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
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Cell Structure & Organelles in detailed.
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
RMMM.pdf make it easy to upload and study
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PPTX
Pharma ospi slides which help in ospi learning
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
master seminar digital applications in india
PPTX
Institutional Correction lecture only . . .
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Final Presentation General Medicine 03-08-2024.pptx
O5-L3 Freight Transport Ops (International) V1.pdf
Cell Structure & Organelles in detailed.
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Renaissance Architecture: A Journey from Faith to Humanism
O7-L3 Supply Chain Operations - ICLT Program
RMMM.pdf make it easy to upload and study
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPH.pptx obstetrics and gynecology in nursing
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Pharma ospi slides which help in ospi learning
VCE English Exam - Section C Student Revision Booklet
FourierSeries-QuestionsWithAnswers(Part-A).pdf
master seminar digital applications in india
Institutional Correction lecture only . . .
Complications of Minimal Access Surgery at WLH
Week 4 Term 3 Study Techniques revisited.pptx
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Microbial disease of the cardiovascular and lymphatic systems

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