SlideShare a Scribd company logo
Lecture 2 python conditional (ewurc)
Python
Lecture 2
Problem Set 2: Conditional
Topic
• Conditional Statement (Decision Making)
• Operator
• Comparisons Operator
• Logical Operator
• Bitwise Operator
• Problem Set 2: Conditional (10)
Conditional Statement Syntax
• if condition:
#statement
• if condition:
#statement
else:
#statement
• if condition:
#statement
elif condition:
#statement
else:
#statement
Find Pass/ Fail.
mark = int(input())
if mark>=33:
print("Pass")
else:
print("Fail")
Find Voter or Not Voter.
age = int(input())
if age>=18:
print("Voter")
else:
print("Not Voter")
Is a number Positive/ Negative/ Zero?
num = int(input())
if num>0:
print("Positive")
elif num<0:
print("Negative")
else:
print("Zero")
Find Grade of Exam.
mark = int(input())
if mark>=80:
print("A+")
elif mark>=70:
print("A")
elif mark>=60:
print("B")
elif mark>=50:
print("C")
elif mark>=40:
print(“D")
elif mark>=33:
print("E")
else:
print("F")
Find Maximum between 2 number.
a = int(input())
b = int(input())
if a>b:
print(a)
else:
print(b)
Find Maximum between 2 number. [2 (no way)]
a = int(input())
b = int(input())
max = max(a, b)
print("{} is maximum".format(max))
Find Minimum between 2 number.
a = int(input())
b = int(input())
if a<b:
print(a)
else:
print(b)
Find Maximum between 3 number.
a = int(input())
b = int(input())
c = int(input())
if a>b and a>c:
print(a)
elif b>a and b>c:
print(b)
else:
print(c)
Find Minimum between 3 number.
a = int(input())
b = int(input())
c = int(input())
if a<b and a<c:
print(a)
elif b<a and b<c:
print(b)
else:
print(c)
Check is a number EVEN or ODD.
num = int(input())
if num%2==0:
print("Even")
else:
print("Odd")
Check is a year Leap Year or Not.
year = int(input())
if year%400==0:
print("Leap Year")
elif year%100==0:
print("Not Leap Year")
elif year%4==0:
print("Leap Year")
else:
print("Not Leap Year")
Check is a year Leap Year or Not. [2]
year = int(input())
if year%4==0 and not(year%100==0) or year%400==0:
print("Leap Year")
else:
print("Not Leap Year")
Comparisons (Relational Operator)
• < (less than)
• <= (less than or equal)
• > (greater than)
• >= (greater than or equal)
• == (equal)
• != (not equal)
• is (object identity)
• is not (negated object identity)
Logical Operator
• and
• or
• not
Bitwise Operator
• (|) bitwise or
• (^) bitwise exclusive or (xor)
• (&) bitwise and
• (<<) left shift
• (>>) right shift
• (~) complement
Problem Set 2: Conditional (10)
• Find Pass/ Fail.
• Find Voter or Not Voter.
• Is a number Positive/ Negative/ Zero?
• Find Grade of Exam.
• Find Maximum between 2 number.
• Find Minimum between 2 number.
• Find Maximum between 3 number.
• Find Minimum between 3 number.
• Check is a number EVEN or ODD.
• Check is a year Leap Year or Not.
Any Question?
Prepared by
Mun Al Mamun
President
East West University Robotics Club
munewu@gmail.com
T h i s s l i d e i s p r o v i d e a s a c o u r s e
m a t e r i a l i n t h e w o r k s h o p
“ W o r k s h o p O n P y t h o n P r o g r a m m i n g ”
O r g a n i z e d b y
E a s t W e s t U n i v e r s i t y R o b o t i c s C l u b
Ad

Recommended

Object oriented programming16 boolean expressions and selection statements
Object oriented programming16 boolean expressions and selection statements
Vaibhav Khanna
 
Tech tut
Tech tut
Ketan Paithankar
 
Accuracy is not designed for imbalanced classification
Accuracy is not designed for imbalanced classification
Ali Madani
 
Chapter 2 Decision Making (Python Programming Lecture)
Chapter 2 Decision Making (Python Programming Lecture)
IoT Code Lab
 
ESIT135 Problem Solving Using Python Notes of Unit-1 and Unit-2
ESIT135 Problem Solving Using Python Notes of Unit-1 and Unit-2
prasadmutkule1
 
Intro to Computer Science - Class 7 slide.pdf
Intro to Computer Science - Class 7 slide.pdf
SidhartoBiswas
 
23CSC101T PSPP python programming - UNIT 3.pdf
23CSC101T PSPP python programming - UNIT 3.pdf
RajeshThanikachalam
 
23CSC101T PSPP python program - UNIT 3.pdf
23CSC101T PSPP python program - UNIT 3.pdf
RajeshThanikachalam
 
Brixton Library Technology Initiative Week1 Recap
Brixton Library Technology Initiative Week1 Recap
Basil Bibi
 
Control of flow of the phyton programming
Control of flow of the phyton programming
TriViccaWibisono
 
Python PCEP Comparison Operators And Conditional Execution
Python PCEP Comparison Operators And Conditional Execution
IHTMINSTITUTE
 
Boolean and conditional logic in Python
Boolean and conditional logic in Python
gsdhindsa
 
Python unit 3 part 1
Python unit 3 part 1
Vikram Nandini
 
Python Laboratory Programming Manual.docx
Python Laboratory Programming Manual.docx
ShylajaS14
 
DayM 4.pptx
DayM 4.pptx
vikashyadav23235277
 
Chaptfffffuuer05.PPT
Chaptfffffuuer05.PPT
sdvdsvsdvsvds
 
PART 4 - Python Tutorial | If Else In Python With Examples
PART 4 - Python Tutorial | If Else In Python With Examples
Shivam Mitra
 
Mastering python lesson2
Mastering python lesson2
Ruth Marvin
 
PYTHON BASICS CODING LANGUAGE GO TO.pptx
PYTHON BASICS CODING LANGUAGE GO TO.pptx
MohammedShoaib663271
 
Operators and Control Statements in Python
Operators and Control Statements in Python
RajeswariA8
 
Python Training in Bangalore | Python Operators | Learnbay.in
Python Training in Bangalore | Python Operators | Learnbay.in
Learnbayin
 
Year 7 lesson 5 if statements
Year 7 lesson 5 if statements
tmoncrieff
 
Python Slides conditioanls and control flow
Python Slides conditioanls and control flow
MuhammadIfitikhar
 
AP COmputer Science Review if and else condition
AP COmputer Science Review if and else condition
ssuser8f59d0
 
Python Conditional_Statements_and_Functions
Python Conditional_Statements_and_Functions
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
Pythonlearn-03-Conditional.pptx
Pythonlearn-03-Conditional.pptx
VigneshChaturvedi1
 
Python Homework Sample
Python Homework Sample
Terrill Shanahan
 
Python Programming | JNTUA | UNIT 2 | Conditionals and Recursion |
Python Programming | JNTUA | UNIT 2 | Conditionals and Recursion |
FabMinds
 
Lecture 1 python arithmetic (ewurc)
Lecture 1 python arithmetic (ewurc)
Al-Mamun Riyadh (Mun)
 
Prime Number (Sieve)
Prime Number (Sieve)
Al-Mamun Riyadh (Mun)
 

More Related Content

Similar to Lecture 2 python conditional (ewurc) (20)

Brixton Library Technology Initiative Week1 Recap
Brixton Library Technology Initiative Week1 Recap
Basil Bibi
 
Control of flow of the phyton programming
Control of flow of the phyton programming
TriViccaWibisono
 
Python PCEP Comparison Operators And Conditional Execution
Python PCEP Comparison Operators And Conditional Execution
IHTMINSTITUTE
 
Boolean and conditional logic in Python
Boolean and conditional logic in Python
gsdhindsa
 
Python unit 3 part 1
Python unit 3 part 1
Vikram Nandini
 
Python Laboratory Programming Manual.docx
Python Laboratory Programming Manual.docx
ShylajaS14
 
DayM 4.pptx
DayM 4.pptx
vikashyadav23235277
 
Chaptfffffuuer05.PPT
Chaptfffffuuer05.PPT
sdvdsvsdvsvds
 
PART 4 - Python Tutorial | If Else In Python With Examples
PART 4 - Python Tutorial | If Else In Python With Examples
Shivam Mitra
 
Mastering python lesson2
Mastering python lesson2
Ruth Marvin
 
PYTHON BASICS CODING LANGUAGE GO TO.pptx
PYTHON BASICS CODING LANGUAGE GO TO.pptx
MohammedShoaib663271
 
Operators and Control Statements in Python
Operators and Control Statements in Python
RajeswariA8
 
Python Training in Bangalore | Python Operators | Learnbay.in
Python Training in Bangalore | Python Operators | Learnbay.in
Learnbayin
 
Year 7 lesson 5 if statements
Year 7 lesson 5 if statements
tmoncrieff
 
Python Slides conditioanls and control flow
Python Slides conditioanls and control flow
MuhammadIfitikhar
 
AP COmputer Science Review if and else condition
AP COmputer Science Review if and else condition
ssuser8f59d0
 
Python Conditional_Statements_and_Functions
Python Conditional_Statements_and_Functions
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
Pythonlearn-03-Conditional.pptx
Pythonlearn-03-Conditional.pptx
VigneshChaturvedi1
 
Python Homework Sample
Python Homework Sample
Terrill Shanahan
 
Python Programming | JNTUA | UNIT 2 | Conditionals and Recursion |
Python Programming | JNTUA | UNIT 2 | Conditionals and Recursion |
FabMinds
 
Brixton Library Technology Initiative Week1 Recap
Brixton Library Technology Initiative Week1 Recap
Basil Bibi
 
Control of flow of the phyton programming
Control of flow of the phyton programming
TriViccaWibisono
 
Python PCEP Comparison Operators And Conditional Execution
Python PCEP Comparison Operators And Conditional Execution
IHTMINSTITUTE
 
Boolean and conditional logic in Python
Boolean and conditional logic in Python
gsdhindsa
 
Python Laboratory Programming Manual.docx
Python Laboratory Programming Manual.docx
ShylajaS14
 
Chaptfffffuuer05.PPT
Chaptfffffuuer05.PPT
sdvdsvsdvsvds
 
PART 4 - Python Tutorial | If Else In Python With Examples
PART 4 - Python Tutorial | If Else In Python With Examples
Shivam Mitra
 
Mastering python lesson2
Mastering python lesson2
Ruth Marvin
 
PYTHON BASICS CODING LANGUAGE GO TO.pptx
PYTHON BASICS CODING LANGUAGE GO TO.pptx
MohammedShoaib663271
 
Operators and Control Statements in Python
Operators and Control Statements in Python
RajeswariA8
 
Python Training in Bangalore | Python Operators | Learnbay.in
Python Training in Bangalore | Python Operators | Learnbay.in
Learnbayin
 
Year 7 lesson 5 if statements
Year 7 lesson 5 if statements
tmoncrieff
 
Python Slides conditioanls and control flow
Python Slides conditioanls and control flow
MuhammadIfitikhar
 
AP COmputer Science Review if and else condition
AP COmputer Science Review if and else condition
ssuser8f59d0
 
Pythonlearn-03-Conditional.pptx
Pythonlearn-03-Conditional.pptx
VigneshChaturvedi1
 
Python Programming | JNTUA | UNIT 2 | Conditionals and Recursion |
Python Programming | JNTUA | UNIT 2 | Conditionals and Recursion |
FabMinds
 

More from Al-Mamun Riyadh (Mun) (8)

Lecture 1 python arithmetic (ewurc)
Lecture 1 python arithmetic (ewurc)
Al-Mamun Riyadh (Mun)
 
Prime Number (Sieve)
Prime Number (Sieve)
Al-Mamun Riyadh (Mun)
 
Workshop on arduino (ewurc)
Workshop on arduino (ewurc)
Al-Mamun Riyadh (Mun)
 
Lecture 6 python oop (ewurc)
Lecture 6 python oop (ewurc)
Al-Mamun Riyadh (Mun)
 
Lecture 5 python function (ewurc)
Lecture 5 python function (ewurc)
Al-Mamun Riyadh (Mun)
 
Lecture 4 python string (ewurc)
Lecture 4 python string (ewurc)
Al-Mamun Riyadh (Mun)
 
Lecture 3.1 python loop 1 (ewurc)
Lecture 3.1 python loop 1 (ewurc)
Al-Mamun Riyadh (Mun)
 
Lecture 0 python basic (ewurc)
Lecture 0 python basic (ewurc)
Al-Mamun Riyadh (Mun)
 
Ad

Recently uploaded (20)

Aprendendo Arquitetura Framework Salesforce - Dia 02
Aprendendo Arquitetura Framework Salesforce - Dia 02
Mauricio Alexandre Silva
 
Hurricane Helene Application Documents Checklists
Hurricane Helene Application Documents Checklists
Mebane Rash
 
Gladiolous Cultivation practices by AKL.pdf
Gladiolous Cultivation practices by AKL.pdf
kushallamichhame
 
VCE Literature Section A Exam Response Guide
VCE Literature Section A Exam Response Guide
jpinnuck
 
A Visual Introduction to the Prophet Jeremiah
A Visual Introduction to the Prophet Jeremiah
Steve Thomason
 
June 2025 Progress Update With Board Call_In process.pptx
June 2025 Progress Update With Board Call_In process.pptx
International Society of Service Innovation Professionals
 
Code Profiling in Odoo 18 - Odoo 18 Slides
Code Profiling in Odoo 18 - Odoo 18 Slides
Celine George
 
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
trjnesjnqg7801
 
K12 Tableau User Group virtual event June 18, 2025
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
HistoPathology Ppt. Arshita Gupta for Diploma
HistoPathology Ppt. Arshita Gupta for Diploma
arshitagupta674
 
2025 June Year 9 Presentation: Subject selection.pptx
2025 June Year 9 Presentation: Subject selection.pptx
mansk2
 
Photo chemistry Power Point Presentation
Photo chemistry Power Point Presentation
mprpgcwa2024
 
How to Customize Quotation Layouts in Odoo 18
How to Customize Quotation Layouts in Odoo 18
Celine George
 
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
parmarjuli1412
 
This is why students from these 44 institutions have not received National Se...
This is why students from these 44 institutions have not received National Se...
Kweku Zurek
 
LDMMIA Shop & Student News Summer Solstice 25
LDMMIA Shop & Student News Summer Solstice 25
LDM & Mia eStudios
 
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
Ronisha Das
 
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
Mayvel Nadal
 
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
parmarjuli1412
 
Aprendendo Arquitetura Framework Salesforce - Dia 02
Aprendendo Arquitetura Framework Salesforce - Dia 02
Mauricio Alexandre Silva
 
Hurricane Helene Application Documents Checklists
Hurricane Helene Application Documents Checklists
Mebane Rash
 
Gladiolous Cultivation practices by AKL.pdf
Gladiolous Cultivation practices by AKL.pdf
kushallamichhame
 
VCE Literature Section A Exam Response Guide
VCE Literature Section A Exam Response Guide
jpinnuck
 
A Visual Introduction to the Prophet Jeremiah
A Visual Introduction to the Prophet Jeremiah
Steve Thomason
 
Code Profiling in Odoo 18 - Odoo 18 Slides
Code Profiling in Odoo 18 - Odoo 18 Slides
Celine George
 
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
trjnesjnqg7801
 
K12 Tableau User Group virtual event June 18, 2025
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
HistoPathology Ppt. Arshita Gupta for Diploma
HistoPathology Ppt. Arshita Gupta for Diploma
arshitagupta674
 
2025 June Year 9 Presentation: Subject selection.pptx
2025 June Year 9 Presentation: Subject selection.pptx
mansk2
 
Photo chemistry Power Point Presentation
Photo chemistry Power Point Presentation
mprpgcwa2024
 
How to Customize Quotation Layouts in Odoo 18
How to Customize Quotation Layouts in Odoo 18
Celine George
 
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
parmarjuli1412
 
This is why students from these 44 institutions have not received National Se...
This is why students from these 44 institutions have not received National Se...
Kweku Zurek
 
LDMMIA Shop & Student News Summer Solstice 25
LDMMIA Shop & Student News Summer Solstice 25
LDM & Mia eStudios
 
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
Ronisha Das
 
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
Mayvel Nadal
 
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
parmarjuli1412
 
Ad

Lecture 2 python conditional (ewurc)

  • 3. Topic • Conditional Statement (Decision Making) • Operator • Comparisons Operator • Logical Operator • Bitwise Operator • Problem Set 2: Conditional (10)
  • 4. Conditional Statement Syntax • if condition: #statement • if condition: #statement else: #statement • if condition: #statement elif condition: #statement else: #statement
  • 5. Find Pass/ Fail. mark = int(input()) if mark>=33: print("Pass") else: print("Fail")
  • 6. Find Voter or Not Voter. age = int(input()) if age>=18: print("Voter") else: print("Not Voter")
  • 7. Is a number Positive/ Negative/ Zero? num = int(input()) if num>0: print("Positive") elif num<0: print("Negative") else: print("Zero")
  • 8. Find Grade of Exam. mark = int(input()) if mark>=80: print("A+") elif mark>=70: print("A") elif mark>=60: print("B") elif mark>=50: print("C") elif mark>=40: print(“D") elif mark>=33: print("E") else: print("F")
  • 9. Find Maximum between 2 number. a = int(input()) b = int(input()) if a>b: print(a) else: print(b)
  • 10. Find Maximum between 2 number. [2 (no way)] a = int(input()) b = int(input()) max = max(a, b) print("{} is maximum".format(max))
  • 11. Find Minimum between 2 number. a = int(input()) b = int(input()) if a<b: print(a) else: print(b)
  • 12. Find Maximum between 3 number. a = int(input()) b = int(input()) c = int(input()) if a>b and a>c: print(a) elif b>a and b>c: print(b) else: print(c)
  • 13. Find Minimum between 3 number. a = int(input()) b = int(input()) c = int(input()) if a<b and a<c: print(a) elif b<a and b<c: print(b) else: print(c)
  • 14. Check is a number EVEN or ODD. num = int(input()) if num%2==0: print("Even") else: print("Odd")
  • 15. Check is a year Leap Year or Not. year = int(input()) if year%400==0: print("Leap Year") elif year%100==0: print("Not Leap Year") elif year%4==0: print("Leap Year") else: print("Not Leap Year")
  • 16. Check is a year Leap Year or Not. [2] year = int(input()) if year%4==0 and not(year%100==0) or year%400==0: print("Leap Year") else: print("Not Leap Year")
  • 17. Comparisons (Relational Operator) • < (less than) • <= (less than or equal) • > (greater than) • >= (greater than or equal) • == (equal) • != (not equal) • is (object identity) • is not (negated object identity)
  • 19. Bitwise Operator • (|) bitwise or • (^) bitwise exclusive or (xor) • (&) bitwise and • (<<) left shift • (>>) right shift • (~) complement
  • 20. Problem Set 2: Conditional (10) • Find Pass/ Fail. • Find Voter or Not Voter. • Is a number Positive/ Negative/ Zero? • Find Grade of Exam. • Find Maximum between 2 number. • Find Minimum between 2 number. • Find Maximum between 3 number. • Find Minimum between 3 number. • Check is a number EVEN or ODD. • Check is a year Leap Year or Not.
  • 22. Prepared by Mun Al Mamun President East West University Robotics Club [email protected] T h i s s l i d e i s p r o v i d e a s a c o u r s e m a t e r i a l i n t h e w o r k s h o p “ W o r k s h o p O n P y t h o n P r o g r a m m i n g ” O r g a n i z e d b y E a s t W e s t U n i v e r s i t y R o b o t i c s C l u b