Início
Conheça mais
Enviar pesquisa
Carregar
Entrar
Cadastre-se
Anúncio
Check these out next
Ch-5.pdf
R.K.College of engg & Tech
Python Flow Control
Mohammed Sikander
Cse lecture-6-c control statement
FarshidKhan
Loops
ShivamPatel466
Loops
Mohammed Alhafyan
Bt0067 c programming and data structures 1
Techglyphs
Basic of Python- Hands on Session
Dharmesh Tank
python.pptx
Poornima116356
1
de
17
Top clipped slide
Ch-4.pdf
25 de Mar de 2023
•
0 gostou
0 gostaram
×
Seja o primeiro a gostar disto
mostrar mais
•
34 visualizações
visualizações
×
Vistos totais
0
No Slideshare
0
De incorporações
0
Número de incorporações
0
Baixar agora
Baixar para ler offline
Denunciar
Engenharia
Python Programing
R.K.College of engg & Tech
Seguir
Assist Proff at ALva's Institute of Engineering and Technology em R.K.College of engg & Tech
Anúncio
Anúncio
Anúncio
Recomendados
Types of Statements in Python Programming Language
Explore Skilled
250 visualizações
•
17 slides
Introduction to Python Part-1
Devashish Kumar
627 visualizações
•
33 slides
Control_Statements_in_Python.pptx
Koteswari Kasireddy
6 visualizações
•
18 slides
PYTHON FULL TUTORIAL WITH PROGRAMMS
Aniruddha Paul
1.2K visualizações
•
114 slides
Programming in Arduino (Part 2)
Niket Chandrawanshi
982 visualizações
•
30 slides
Python session3
Aswin Krishnamoorthy
392 visualizações
•
15 slides
Mais conteúdo relacionado
Similar a Ch-4.pdf
(20)
Ch-5.pdf
R.K.College of engg & Tech
•
9 visualizações
Python Flow Control
Mohammed Sikander
•
3.7K visualizações
Cse lecture-6-c control statement
FarshidKhan
•
132 visualizações
Loops
ShivamPatel466
•
110 visualizações
Loops
Mohammed Alhafyan
•
146 visualizações
Bt0067 c programming and data structures 1
Techglyphs
•
96 visualizações
Basic of Python- Hands on Session
Dharmesh Tank
•
130 visualizações
python.pptx
Poornima116356
•
5 visualizações
Introduction to Python for Data Science and Machine Learning
ParrotAI
•
547 visualizações
Control structures pyhton
Prakash Jayaraman
•
101 visualizações
R loops
Learnbay Datascience
•
36 visualizações
Loops IN COMPUTER SCIENCE STANDARD 11 BY KR
Krishna Raj
•
706 visualizações
Final requirement
arjoy_dimaculangan
•
554 visualizações
Loops c++
Shivani Singh
•
16.8K visualizações
Password protected diary
SHARDA SHARAN
•
2.1K visualizações
The Loops
Krishma Parekh
•
14K visualizações
An Introduction to Computer Science with Java, Python an.docx
amrit47
•
2 visualizações
Loop in C Properties & Applications
Emroz Sardar
•
292 visualizações
Arduino Functions
mahalakshmimalini
•
224 visualizações
Chapter 9 Conditional and Iterative Statements.pptx
XhelalSpahiu
•
185 visualizações
Mais de R.K.College of engg & Tech
(13)
Module 5(Matplotlib and tkinter).pdf
R.K.College of engg & Tech
•
6 visualizações
Module 5(Numpy).pdf
R.K.College of engg & Tech
•
5 visualizações
Module 5(Pandas).pdf
R.K.College of engg & Tech
•
4 visualizações
Module IV_updated(old).pdf
R.K.College of engg & Tech
•
6 visualizações
Module III.pdf
R.K.College of engg & Tech
•
8 visualizações
Python_Module_2.pdf
R.K.College of engg & Tech
•
5 visualizações
Python_Module_1.pdf
R.K.College of engg & Tech
•
8 visualizações
Python for Data Analysis_ Data Wrangling with Pandas, Numpy, and Ipython ( PD...
R.K.College of engg & Tech
•
36 visualizações
Ch-8.pdf
R.K.College of engg & Tech
•
15 visualizações
Ch-3.pdf
R.K.College of engg & Tech
•
10 visualizações
Creating Interface- Practice Program 6.docx
R.K.College of engg & Tech
•
3 visualizações
Practice Program-9-Packages-Unit 4.docx
R.K.College of engg & Tech
•
6 visualizações
Unit-3 Practice Programs-5.docx
R.K.College of engg & Tech
•
4 visualizações
Anúncio
Último
(20)
Design of a solar air heater using feature-mapping methods
Fabian Wein
•
0 visão
Algebric Functions.pdf
MamadArip
•
0 visão
Jindal-Steel-Structure-Brochure
JindalStructural
•
0 visão
TECHNICAL SEMINAR FRONT PAGE 1.pptx
swethamurugan15
•
0 visão
data analysis.pptx
TanguduTejeswarRao
•
0 visão
AUTOMATIC SOLAR TRACKER.pptx
praveenkumar971811
•
0 visão
ujjwal.pptx
superNayrking
•
0 visão
Week 5 - Electric Current and Circuits.pptx
MarkReySaquez
•
0 visão
Navy Aircraft Armament.pdf
TahirSadikovi
•
0 visão
osha3075.pdf
Sundharamoorthy8
•
0 visão
IARE_RS_PPT_0.pdf
amitkumar473416
•
0 visão
devsecops-reference-architectures-2018.pdf
EvinHernandez1
•
0 visão
SKYLAB Illustrated Chronology.pdf
TahirSadikovi
•
0 visão
Final (3).pptx
RohitYadav429441
•
0 visão
Gauges and comparators.pptx
HamzaAli333395
•
0 visão
WIRELESS LOCKSYSTEM THROUGH OTP.docx
AnimeshBasak13
•
0 visão
SMC_PANEL_TANK___PHOTOS_pdf[1].pptx
abhichid
•
0 visão
20220818151924_PPT01 - The Logic of Compound and Quantitative Statement.pptx
ssuser92109d
•
0 visão
FibreFlow - Drum Pulper - Andritz.pdf
Claudinei Mayer
•
0 visão
Introduction-to-Radar-Lecture-1-Material.pdf
amitkumar473416
•
0 visão
Ch-4.pdf
Python Programming ing Problem
Solving Approach Reema Thareja 1 © OXFORD UNIVERSITY PRESS 2017. ALL RIGHTS RESERVED. 1
© OXFORD UNIVERSITY
PRESS 2017. ALL RIGHTS RESERVED. 2 CHAPTER 4 Decision Control Statements
© OXFORD UNIVERSITY
PRESS 2017. ALL RIGHTS RESERVED. 3 Control Statements A control statement is a statement that determines the control flow of a set of instructions, i.e., it decides the sequence in which the instructions in a program are to be executed. Types of Control Statements — • Sequential Control: A Python program is executed sequentially from the first line of the program to its last line. • Selection Control: To execute only a selected set of statements. • Iterative Control: To execute a set of statements repeatedly.
If Statement © OXFORD
UNIVERSITY PRESS 2017. ALL RIGHTS RESERVED. 4 Example:
If-Else Statement © OXFORD
UNIVERSITY PRESS 2017. ALL RIGHTS RESERVED. 5 Example:
Nested if Statements ©
OXFORD UNIVERSITY PRESS 2017. ALL RIGHTS RESERVED. 6 A statement that contains other statements is called a compound statement. To perform more complex checks, if statements can be nested, that is, can be placed one inside the other. In such a case, the inner if statement is the statement part of the outer one. Nested if statements are used to check if more than one conditions are satisfied. Example:
If-elif-else Statement © OXFORD
UNIVERSITY PRESS 2017. ALL RIGHTS RESERVED. 7 Python supports if-elif-else statements to test additional conditions apart from the initial test expression. The if-elif-else construct works in the same way as a usual if- else statement. If-elif-else construct is also known as nested-if construct. Example:
While Loop © OXFORD
UNIVERSITY PRESS 2017. ALL RIGHTS RESERVED. 8 Example:
For Loop © OXFORD
UNIVERSITY PRESS 2017. ALL RIGHTS RESERVED. 9 For loop provides a mechanism to repeat a task until a particular condition is True. It is usually known as a determinate or definite loop because the programmer knows exactly how many times the loop will repeat. The for...in statement is a looping statement used in Python to iterate over a sequence of objects.
For Loop and
Range() Function © OXFORD UNIVERSITY PRESS 2017. ALL RIGHTS RESERVED. 10 The range() function is a built-in function in Python that is used to iterate over a sequence of numbers. The syntax of range() is range(beg, end, [step]) The range() produces a sequence of numbers starting with beg (inclusive) and ending with one less than the number end. The step argument is option (that is why it is placed in brackets). By default, every number in the range is incremented by 1 but we can specify a different increment using step. It can be both negative and positive, but not zero. Examples:
Range() Function © OXFORD
UNIVERSITY PRESS 2017. ALL RIGHTS RESERVED. 11 If range() function is given a single argument, it produces an object with values from 0 to argument-1. For example: range(10) is equal to writing range(0, 10). • If range() is called with two arguments, it produces values from the first to the second. For example, range(0,10). • If range() has three arguments then the third argument specifies the interval of the sequence produced. In this case, the third argument must be an integer. For example, range(1,20,3). Examples:
Condition-controlled and Counter-controlled
Loops © OXFORD UNIVERSITY PRESS 2017. ALL RIGHTS RESERVED. 12
Nested Loops © OXFORD
UNIVERSITY PRESS 2017. ALL RIGHTS RESERVED. 13 Python allows its users to have nested loops, that is, loops that can be placed inside other loops. Although this feature will work with any loop like while loop as well as for loop. A for loop can be used to control the number of times a particular set of statements will be executed. Another outer loop could be used to control the number of times that a whole loop is repeated. Loops should be properly indented to identify which statements are contained within each for statement. Example:
The Break Statement ©
OXFORD UNIVERSITY PRESS 2017. ALL RIGHTS RESERVED. 14 The break statement is used to terminate the execution of the nearest enclosing loop in which it appears. The break statement is widely used with for loop and while loop. When compiler encounters a break statement, the control passes to the statement that follows the loop in which the break statement appears. Example:
The Continue Statement ©
OXFORD UNIVERSITY PRESS 2017. ALL RIGHTS RESERVED. 15 Like the break statement, the continue statement can only appear in the body of a loop. When the compiler encounters a continue statement then the rest of the statements in the loop are skipped and the control is unconditionally transferred to the loop- continuation portion of the nearest enclosing loop. Example:
The Pass Statement ©
OXFORD UNIVERSITY PRESS 2017. ALL RIGHTS RESERVED. 16 Pass statement is used when a statement is required syntactically but no command or code has to be executed. It specified a null operation or simply No Operation (NOP) statement. Nothing happens when the pass statement is executed. Difference between comment and pass statements In Python programming, pass is a null statement. The difference between a comment and pass statement is that while the interpreter ignores a comment entirely, pass is not ignored. Comment is not executed but pass statement is executed but nothing happens. Example:
The Else Statement
Used With Loops © OXFORD UNIVERSITY PRESS 2017. ALL RIGHTS RESERVED. 17 Unlike C and C++, in Python you can have the else statement associated with a loop statements. If the else statement is used with a for loop, the else statement is executed when the loop has completed iterating. But when used with the while loop, the else statement is executed when the condition becomes false. Examples:
Anúncio