SlideShare a Scribd company logo
1 of 15
AGENDA

Decision Making
Loops
Python Decision Making


Decision making structures require that the
programmer specify one or more conditions to be
evaluated or tested by the program, along with a
statement or statements to be executed if the condition is
determined to be true, and optionally, other statements to
be executed if the condition is determined to be false.
Types of decision making
statements
 IF statements
 IF...ELSE statements
 Nested IF statements
IF statements Flow Diagram:

Test Exp

FALSE

TRUE

Body of if

EXIT
IF...ELSE statements Flow Diagram:

Test Exp

FALSE

If Block

TRUE

Body of Else



EXIT
The else statement is an optional statement and there could be at most only one
else statement following if .
LOOPS




A loop statement allows us to execute a statement or
group of statements multiple times
Python programming language provides following types
of loops to handle looping requirements

 While loop
 For loop
While Loop
Example:
count = 0
while (count < 9):
print 'The count is:', count
count = count + 1
print "Good bye!"
For Loop
If a sequence contains an expression list, it is
evaluated first. Then, the first item in the sequence is
assigned to the iterating variable iterating_var. Next, the
statements block is executed. Each item in the list is
assigned to iterating_var, and the statement(s) block is
executed until the entire sequence is exhausted.
Example:
for letter in 'Python':
print 'Current Letter :', letter

String
Loop Control Statements:
Loop control statements change execution from its
normal sequence. When execution leaves a scope, all
automatic objects that were created in that scope are
destroyed.


break statement



continue statement



pass statement
Break Statement:

Example
for letter in 'Python':
if letter == 'h':
break

Break Statement

print 'Current Letter :', letter
continue statement
The continue statement in Python returns the control
to the beginning of the while loop. The continue
statement rejects all the remaining statements in the
current iteration of the loop and moves the control back
to the top of the loop.
for letter in 'Python':
if letter == 'h':
continue

continue statement

print 'Current Letter :', letter
pass statement
The pass statement in Python is used when a statement
is required syntactically but you do not want any
command or code to execute.
The pass statement is a null operation; nothing happens
when it executes.
for letter in 'Python':
if letter == 'h':
pass
print 'This is pass block'
print 'Current Letter :', letter
Reference


http://www.tutorialspoint.com/python/
Python session3

More Related Content

What's hot (20)

Comp ppt (1)
Comp ppt (1)Comp ppt (1)
Comp ppt (1)
 
Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in Java
 
Python loops
Python loopsPython loops
Python loops
 
Chap 6(decision making-looping)
Chap 6(decision making-looping)Chap 6(decision making-looping)
Chap 6(decision making-looping)
 
Loops in C Programming | for Loop | do-while Loop | while Loop | Nested Loop
Loops in C Programming | for Loop | do-while Loop | while Loop | Nested LoopLoops in C Programming | for Loop | do-while Loop | while Loop | Nested Loop
Loops in C Programming | for Loop | do-while Loop | while Loop | Nested Loop
 
Control structures
Control structuresControl structures
Control structures
 
Loops in C Programming Language
Loops in C Programming LanguageLoops in C Programming Language
Loops in C Programming Language
 
Kelompok 8 Pbw
Kelompok 8 PbwKelompok 8 Pbw
Kelompok 8 Pbw
 
Kelompok 8 Pbw
Kelompok 8 PbwKelompok 8 Pbw
Kelompok 8 Pbw
 
Types of loops in c language
Types of loops in c languageTypes of loops in c language
Types of loops in c language
 
Looping
LoopingLooping
Looping
 
Looping in c++
Looping in c++Looping in c++
Looping in c++
 
Loops
LoopsLoops
Loops
 
While , For , Do-While Loop
While , For , Do-While LoopWhile , For , Do-While Loop
While , For , Do-While Loop
 
Control statements
Control statementsControl statements
Control statements
 
Flow of control ppt
Flow of control pptFlow of control ppt
Flow of control ppt
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
 
Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)
 
Looping in c++
Looping in c++Looping in c++
Looping in c++
 
Looping statements
Looping statementsLooping statements
Looping statements
 

Viewers also liked

Tugassejaraharsitektur 131112083046-phpapp01
Tugassejaraharsitektur 131112083046-phpapp01Tugassejaraharsitektur 131112083046-phpapp01
Tugassejaraharsitektur 131112083046-phpapp01frans2014
 
μυστράς (2)
μυστράς (2)μυστράς (2)
μυστράς (2)Theod13
 
Tradie Exchange Jobs - Referrals in Australia
Tradie Exchange Jobs - Referrals in AustraliaTradie Exchange Jobs - Referrals in Australia
Tradie Exchange Jobs - Referrals in AustraliaTradieExchange
 
Virtualization session3 vm installation
Virtualization session3 vm installationVirtualization session3 vm installation
Virtualization session3 vm installationAswin Krishnamoorthy
 
Tradie Exchange Jobs - Hiring in Australia
Tradie Exchange Jobs - Hiring in AustraliaTradie Exchange Jobs - Hiring in Australia
Tradie Exchange Jobs - Hiring in AustraliaTradieExchange
 
Perencanaan sambungan-profil-baja
Perencanaan sambungan-profil-bajaPerencanaan sambungan-profil-baja
Perencanaan sambungan-profil-bajafrans2014
 
გარემოს დაცვის კლუბების მნიშვნელობა
გარემოს დაცვის კლუბების მნიშვნელობაგარემოს დაცვის კლუბების მნიშვნელობა
გარემოს დაცვის კლუბების მნიშვნელობაNato Khuroshvili
 
παρουσίαση προγράμματος
παρουσίαση προγράμματοςπαρουσίαση προγράμματος
παρουσίαση προγράμματοςTheod13
 
An RGB Laser And Its Applications
An RGB Laser And Its ApplicationsAn RGB Laser And Its Applications
An RGB Laser And Its Applicationsznsaja
 
2016 IoT Business Forum
2016 IoT Business Forum2016 IoT Business Forum
2016 IoT Business ForumMarlos Bosso
 
Μυστράς Α
Μυστράς ΑΜυστράς Α
Μυστράς ΑTheod13
 
Analisa ecotects
Analisa ecotectsAnalisa ecotects
Analisa ecotectsfrans2014
 
[S hegda a.v.]_ekonomіka_pіdpriєmstva._zbіrnik_(book_fi.org)
[S hegda a.v.]_ekonomіka_pіdpriєmstva._zbіrnik_(book_fi.org)[S hegda a.v.]_ekonomіka_pіdpriєmstva._zbіrnik_(book_fi.org)
[S hegda a.v.]_ekonomіka_pіdpriєmstva._zbіrnik_(book_fi.org)інна гаврилець
 
Ppipp copy-130823044640-phpapp02
Ppipp copy-130823044640-phpapp02Ppipp copy-130823044640-phpapp02
Ppipp copy-130823044640-phpapp02frans2014
 
Modulmekanikateknik1 121101215953-phpapp01
Modulmekanikateknik1 121101215953-phpapp01Modulmekanikateknik1 121101215953-phpapp01
Modulmekanikateknik1 121101215953-phpapp01frans2014
 

Viewers also liked (18)

Tugassejaraharsitektur 131112083046-phpapp01
Tugassejaraharsitektur 131112083046-phpapp01Tugassejaraharsitektur 131112083046-phpapp01
Tugassejaraharsitektur 131112083046-phpapp01
 
μυστράς (2)
μυστράς (2)μυστράς (2)
μυστράς (2)
 
Tradie Exchange Jobs - Referrals in Australia
Tradie Exchange Jobs - Referrals in AustraliaTradie Exchange Jobs - Referrals in Australia
Tradie Exchange Jobs - Referrals in Australia
 
Virtualization session3 vm installation
Virtualization session3 vm installationVirtualization session3 vm installation
Virtualization session3 vm installation
 
Tradie Exchange Jobs - Hiring in Australia
Tradie Exchange Jobs - Hiring in AustraliaTradie Exchange Jobs - Hiring in Australia
Tradie Exchange Jobs - Hiring in Australia
 
Perencanaan sambungan-profil-baja
Perencanaan sambungan-profil-bajaPerencanaan sambungan-profil-baja
Perencanaan sambungan-profil-baja
 
გარემოს დაცვის კლუბების მნიშვნელობა
გარემოს დაცვის კლუბების მნიშვნელობაგარემოს დაცვის კლუბების მნიშვნელობა
გარემოს დაცვის კლუბების მნიშვნელობა
 
παρουσίαση προγράμματος
παρουσίαση προγράμματοςπαρουσίαση προγράμματος
παρουσίαση προγράμματος
 
An RGB Laser And Its Applications
An RGB Laser And Its ApplicationsAn RGB Laser And Its Applications
An RGB Laser And Its Applications
 
δ.θ
δ.θδ.θ
δ.θ
 
2016 IoT Business Forum
2016 IoT Business Forum2016 IoT Business Forum
2016 IoT Business Forum
 
Μυστράς Α
Μυστράς ΑΜυστράς Α
Μυστράς Α
 
Analisa ecotects
Analisa ecotectsAnalisa ecotects
Analisa ecotects
 
[S hegda a.v.]_ekonomіka_pіdpriєmstva._zbіrnik_(book_fi.org)
[S hegda a.v.]_ekonomіka_pіdpriєmstva._zbіrnik_(book_fi.org)[S hegda a.v.]_ekonomіka_pіdpriєmstva._zbіrnik_(book_fi.org)
[S hegda a.v.]_ekonomіka_pіdpriєmstva._zbіrnik_(book_fi.org)
 
Ppipp copy-130823044640-phpapp02
Ppipp copy-130823044640-phpapp02Ppipp copy-130823044640-phpapp02
Ppipp copy-130823044640-phpapp02
 
Html
HtmlHtml
Html
 
Python slide.1
Python slide.1Python slide.1
Python slide.1
 
Modulmekanikateknik1 121101215953-phpapp01
Modulmekanikateknik1 121101215953-phpapp01Modulmekanikateknik1 121101215953-phpapp01
Modulmekanikateknik1 121101215953-phpapp01
 

Similar to Python session3

Types of Statements in Python Programming Language
Types of Statements in Python Programming LanguageTypes of Statements in Python Programming Language
Types of Statements in Python Programming LanguageExplore Skilled
 
control statements in python.pptx
control statements in python.pptxcontrol statements in python.pptx
control statements in python.pptxAnshu Varma
 
Introduction To Programming with Python Lecture 2
Introduction To Programming with Python Lecture 2Introduction To Programming with Python Lecture 2
Introduction To Programming with Python Lecture 2Syed Farjad Zia Zaidi
 
PYTHON FULL TUTORIAL WITH PROGRAMMS
PYTHON FULL TUTORIAL WITH PROGRAMMSPYTHON FULL TUTORIAL WITH PROGRAMMS
PYTHON FULL TUTORIAL WITH PROGRAMMSAniruddha Paul
 
ppt python notes list tuple data types ope
ppt python notes list tuple data types opeppt python notes list tuple data types ope
ppt python notes list tuple data types opeSukhpreetSingh519414
 
class interview demo
class interview demo class interview demo
class interview demo HELP4STUDENTS
 
Demo for Class.pptx
 Demo for Class.pptx Demo for Class.pptx
Demo for Class.pptxHELP4STUDENTS
 
PPT_203105211_3.pptx
PPT_203105211_3.pptxPPT_203105211_3.pptx
PPT_203105211_3.pptxSaurabhNage1
 
FLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONFLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONvikram mahendra
 
Introduction to Python Part-1
Introduction to Python Part-1Introduction to Python Part-1
Introduction to Python Part-1Devashish Kumar
 
Flow of control C ++ By TANUJ
Flow of control C ++ By TANUJFlow of control C ++ By TANUJ
Flow of control C ++ By TANUJTANUJ ⠀
 
6 Iterative Statements.pptx
6 Iterative Statements.pptx6 Iterative Statements.pptx
6 Iterative Statements.pptxssuser8e50d8
 
if else python.pdf
if else python.pdfif else python.pdf
if else python.pdfGshs6
 

Similar to Python session3 (20)

iterations.docx
iterations.docxiterations.docx
iterations.docx
 
Types of Statements in Python Programming Language
Types of Statements in Python Programming LanguageTypes of Statements in Python Programming Language
Types of Statements in Python Programming Language
 
control statements in python.pptx
control statements in python.pptxcontrol statements in python.pptx
control statements in python.pptx
 
Unit - 2 CAP.pptx
Unit - 2 CAP.pptxUnit - 2 CAP.pptx
Unit - 2 CAP.pptx
 
Introduction To Programming with Python Lecture 2
Introduction To Programming with Python Lecture 2Introduction To Programming with Python Lecture 2
Introduction To Programming with Python Lecture 2
 
PYTHON FULL TUTORIAL WITH PROGRAMMS
PYTHON FULL TUTORIAL WITH PROGRAMMSPYTHON FULL TUTORIAL WITH PROGRAMMS
PYTHON FULL TUTORIAL WITH PROGRAMMS
 
ppt python notes list tuple data types ope
ppt python notes list tuple data types opeppt python notes list tuple data types ope
ppt python notes list tuple data types ope
 
class interview demo
class interview demo class interview demo
class interview demo
 
python
pythonpython
python
 
Demo for Class.pptx
 Demo for Class.pptx Demo for Class.pptx
Demo for Class.pptx
 
PPT_203105211_3.pptx
PPT_203105211_3.pptxPPT_203105211_3.pptx
PPT_203105211_3.pptx
 
FLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONFLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHON
 
Introduction to Python Part-1
Introduction to Python Part-1Introduction to Python Part-1
Introduction to Python Part-1
 
Flow of control C ++ By TANUJ
Flow of control C ++ By TANUJFlow of control C ++ By TANUJ
Flow of control C ++ By TANUJ
 
Programming in Arduino (Part 2)
Programming in Arduino  (Part 2)Programming in Arduino  (Part 2)
Programming in Arduino (Part 2)
 
6 Iterative Statements.pptx
6 Iterative Statements.pptx6 Iterative Statements.pptx
6 Iterative Statements.pptx
 
if else python.pdf
if else python.pdfif else python.pdf
if else python.pdf
 
python.pptx
python.pptxpython.pptx
python.pptx
 
Loops
LoopsLoops
Loops
 
Ch-4.pdf
Ch-4.pdfCh-4.pdf
Ch-4.pdf
 

Recently uploaded

Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxNikitaBankoti2
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesShubhangi Sonawane
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 

Recently uploaded (20)

Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 

Python session3

  • 1.
  • 3. Python Decision Making  Decision making structures require that the programmer specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false.
  • 4. Types of decision making statements  IF statements  IF...ELSE statements  Nested IF statements
  • 5. IF statements Flow Diagram: Test Exp FALSE TRUE Body of if EXIT
  • 6. IF...ELSE statements Flow Diagram: Test Exp FALSE If Block TRUE Body of Else  EXIT The else statement is an optional statement and there could be at most only one else statement following if .
  • 7. LOOPS   A loop statement allows us to execute a statement or group of statements multiple times Python programming language provides following types of loops to handle looping requirements  While loop  For loop
  • 8. While Loop Example: count = 0 while (count < 9): print 'The count is:', count count = count + 1 print "Good bye!"
  • 9. For Loop If a sequence contains an expression list, it is evaluated first. Then, the first item in the sequence is assigned to the iterating variable iterating_var. Next, the statements block is executed. Each item in the list is assigned to iterating_var, and the statement(s) block is executed until the entire sequence is exhausted. Example: for letter in 'Python': print 'Current Letter :', letter String
  • 10. Loop Control Statements: Loop control statements change execution from its normal sequence. When execution leaves a scope, all automatic objects that were created in that scope are destroyed.  break statement  continue statement  pass statement
  • 11. Break Statement: Example for letter in 'Python': if letter == 'h': break Break Statement print 'Current Letter :', letter
  • 12. continue statement The continue statement in Python returns the control to the beginning of the while loop. The continue statement rejects all the remaining statements in the current iteration of the loop and moves the control back to the top of the loop. for letter in 'Python': if letter == 'h': continue continue statement print 'Current Letter :', letter
  • 13. pass statement The pass statement in Python is used when a statement is required syntactically but you do not want any command or code to execute. The pass statement is a null operation; nothing happens when it executes. for letter in 'Python': if letter == 'h': pass print 'This is pass block' print 'Current Letter :', letter