Movatterモバイル変換


[0]ホーム

URL:


PDF, PPTX4,378 views

Python programming : Control statements

The document provides an overview of control statements in programming, including single and multiple statements for control flow using 'if', 'if-else', 'while', and 'for'. It includes syntax examples and explanations for 'break', 'continue', 'pass', and 'assert', as well as handling exceptions with 'try-except'. The content serves as a guide for understanding how to implement control statements and handle conditions in code.

Embed presentation

Download as PDF, PPTX
Control StatementsTeam Emertxe
Single Control Statements
If StatementsIf-Else Syntaxif condition:statementselse:statementsExampleif num % 2:print("ODD")else:print("EVEN")
If StatementsIf-Elif-Else Syntaxif condition1:statementselif condition2:statementselsestatementsExampleif num == 1:print("You entered 1")elif num == 2:print("You entered 2")else:print("You entered 3")
Multiple Control Statements
Multiple StatementsWhile Syntaxwhile condition:statementsExamplei = 1while i <= 10:print(i)i = i + 1
Multiple StatementsFor Syntaxfor var in sequence:statementsExample-v1.1str = "Hello"for ch in str:print(ch, end='')Example-v1.2n = len(str)for i in range(n):print(str[i])
Else Suite
Multiple StatementsFor with Else suite Syntaxfor var in sequence:statement / statementselse:statement / statementsExamplefor i in range(5):print(i)else:print("Over")
Multiple StatementsWhile with Else suite Syntaxwhile condition:statement / statementselse:statement / statementsExamplei = 0while i < 5print(i)i += 1else:print("Over")While searching an elemnt in the sequence is not found,else will be the best option to display the item not found
Misc Statements
Misc StatementsBreak Examplex = 10while x >= 1:print("x = ", x)x -= 1if x == 5:break
Misc StatementsContinue Examplex = 10while x >= 1:if x == 5:x -= 1continueprint("x = ", x)x -= 1
Misc StatementsPass Example-1x = 0while x < 10:x += 1if x == 5:passprint(x)
Misc StatementsPass Example-2: Program to retrieve only the negative numbers from the listnum = [1, 2, 3, -4, -5, -6, 7, 8]for i in num:if (i > 0):passelse:print(i)Pass does nothing
Misc StatementsAssert Syntax:assert expression, message Example-1num = int(input("Enter the number greater than zero: "))assert num > 0, "Wrong input"print("Num: ", num)
Misc StatementsAssert: Try Except Example-1num = int(input("Enter the number greater than zero: "))try:assert num > 0, "Wrong input"print("Num: ", num)except AssertionError:print("You entered wrong input")print("Enter positive number")
Misc StatementsReturn Example-1: To add two numbers & return the resultdef sum(a, b):return a + bres = sum(5, 10)print(res)
THANK YOU

Recommended

PPTX
Python Flow Control
PDF
Python programming : Standard Input and Output
PPTX
Python ppt
PPT
Python Control structures
PDF
Python If Else | If Else Statement In Python | Edureka
PDF
Python programming : Strings
PPTX
Conditional and control statement
PDF
Datatypes in python
PPTX
Looping Statements and Control Statements in Python
PDF
Python exception handling
PDF
Introduction to Python
PDF
Python functions
PPTX
Functions in python slide share
PPTX
Python Exception Handling
PDF
Python programming : Files
PPTX
Conditional Statement in C Language
PDF
Python Flow Control
PPTX
control statements in python.pptx
PPTX
Regular expressions in Python
PPTX
Functions in python
PPTX
Loops c++
PPT
Class and object in C++
PPTX
File Management in C
PPTX
Type conversion
PPSX
Modules and packages in python
PDF
loops.pdf
PDF
conditionalanddvfvdfvdvdcontrolstatement-171023101126.pdf

More Related Content

PPTX
Python Flow Control
PDF
Python programming : Standard Input and Output
PPTX
Python ppt
PPT
Python Control structures
PDF
Python If Else | If Else Statement In Python | Edureka
PDF
Python programming : Strings
Python Flow Control
Python programming : Standard Input and Output
Python ppt
Python Control structures
Python If Else | If Else Statement In Python | Edureka
Python programming : Strings

What's hot

PPTX
Conditional and control statement
PDF
Datatypes in python
PPTX
Looping Statements and Control Statements in Python
PDF
Python exception handling
PDF
Introduction to Python
PDF
Python functions
PPTX
Functions in python slide share
PPTX
Python Exception Handling
PDF
Python programming : Files
PPTX
Conditional Statement in C Language
PDF
Python Flow Control
PPTX
control statements in python.pptx
PPTX
Regular expressions in Python
PPTX
Functions in python
PPTX
Loops c++
PPT
Class and object in C++
PPTX
File Management in C
PPTX
Type conversion
PPSX
Modules and packages in python
Conditional and control statement
Datatypes in python
Looping Statements and Control Statements in Python
Python exception handling
Introduction to Python
Python functions
Functions in python slide share
Python Exception Handling
Python programming : Files
Conditional Statement in C Language
Python Flow Control
control statements in python.pptx
Regular expressions in Python
Functions in python
Loops c++
Class and object in C++
File Management in C
Type conversion
Modules and packages in python

Similar to Python programming : Control statements

PDF
loops.pdf
PDF
conditionalanddvfvdfvdvdcontrolstatement-171023101126.pdf
PDF
Slide 6_Control Structures.pdf
PPTX
1. control structures in the python.pptx
PPTX
Introduction to Python Part-1
PPTX
Python statements
PDF
E-Notes_3721_Content_Document_20250107032537PM.pdf
PPSX
class interview demo
PPTX
Demo for Class.pptx
PPTX
python
PPTX
ControlStructures.pptx5t54t54444444444444444
PPTX
Unit - 2 CAP.pptx
PDF
Python unit 2 M.sc cs
PPTX
Week 4.pptx computational thinking and programming
PPTX
Python Flow Control & use of functions.pptx
PPTX
Chapter 9 Conditional and Iterative Statements.pptx
PPTX
module 2.pptx
PPTX
Control_Statements.pptx
PPTX
Introduction to Python programming
PPTX
Python lec3
loops.pdf
conditionalanddvfvdfvdvdcontrolstatement-171023101126.pdf
Slide 6_Control Structures.pdf
1. control structures in the python.pptx
Introduction to Python Part-1
Python statements
E-Notes_3721_Content_Document_20250107032537PM.pdf
class interview demo
Demo for Class.pptx
python
ControlStructures.pptx5t54t54444444444444444
Unit - 2 CAP.pptx
Python unit 2 M.sc cs
Week 4.pptx computational thinking and programming
Python Flow Control & use of functions.pptx
Chapter 9 Conditional and Iterative Statements.pptx
module 2.pptx
Control_Statements.pptx
Introduction to Python programming
Python lec3

More from Emertxe Information Technologies Pvt Ltd

PDF
PDF
Career Transition (1).pdf
PDF
PDF
PDF
Career Transition (1).pdf

Recently uploaded

PDF
Mulesoft Meetup Online Portuguese: MCP e IA
PDF
Agentic Intro and Hands-on: Build your first Coded Agent
PDF
PCCC25(設立25年記念PCクラスタシンポジウム):エヌビディア合同会社 テーマ2「NVIDIA BlueField-4 DPU」
PDF
Top Crypto Supers 15th Report November 2025
PDF
[BDD 2025 - Artificial Intelligence] AI for the Underdogs: Innovation for Sma...
PDF
The partnership effect: Libraries and publishers on collaborating and thrivin...
PPTX
Support, Monitoring, Continuous Improvement & Scaling Agentic Automation [3/3]
PDF
How Much Does It Cost To Build Software
PDF
[BDD 2025 - Full-Stack Development] Agentic AI Architecture: Redefining Syste...
PDF
Mastering UiPath Maestro – Session 2 – Building a Live Use Case - Session 2
PDF
Mastering Agentic Orchestration with UiPath Maestro | Hands on Workshop
PDF
Transcript: The partnership effect: Libraries and publishers on collaborating...
PPTX
The power of Slack and MuleSoft | Bangalore MuleSoft Meetup #60
PDF
"DISC as GPS for team leaders: how to lead a team from storming to performing...
 
PDF
The Necessity of Digital Forensics, the Digital Forensics Process & Laborator...
PDF
Cybersecurity Prevention and Detection: Unit 2
PDF
MuleSoft Meetup: Dreamforce'25 Tour- Vibing With AI & Agents.pdf
PDF
[DevFest Strasbourg 2025] - NodeJs Can do that !!
PDF
DUBAI IT MODERNIZATION WITH AZURE MANAGED SERVICES.pdf
PPTX
Guardrails in Action - Ensuring Safe AI with Azure AI Content Safety.pptx
Mulesoft Meetup Online Portuguese: MCP e IA
Agentic Intro and Hands-on: Build your first Coded Agent
PCCC25(設立25年記念PCクラスタシンポジウム):エヌビディア合同会社 テーマ2「NVIDIA BlueField-4 DPU」
Top Crypto Supers 15th Report November 2025
[BDD 2025 - Artificial Intelligence] AI for the Underdogs: Innovation for Sma...
The partnership effect: Libraries and publishers on collaborating and thrivin...
Support, Monitoring, Continuous Improvement & Scaling Agentic Automation [3/3]
How Much Does It Cost To Build Software
[BDD 2025 - Full-Stack Development] Agentic AI Architecture: Redefining Syste...
Mastering UiPath Maestro – Session 2 – Building a Live Use Case - Session 2
Mastering Agentic Orchestration with UiPath Maestro | Hands on Workshop
Transcript: The partnership effect: Libraries and publishers on collaborating...
The power of Slack and MuleSoft | Bangalore MuleSoft Meetup #60
"DISC as GPS for team leaders: how to lead a team from storming to performing...
 
The Necessity of Digital Forensics, the Digital Forensics Process & Laborator...
Cybersecurity Prevention and Detection: Unit 2
MuleSoft Meetup: Dreamforce'25 Tour- Vibing With AI & Agents.pdf
[DevFest Strasbourg 2025] - NodeJs Can do that !!
DUBAI IT MODERNIZATION WITH AZURE MANAGED SERVICES.pdf
Guardrails in Action - Ensuring Safe AI with Azure AI Content Safety.pptx

Python programming : Control statements


[8]ページ先頭

©2009-2025 Movatter.jp