Professional Documents
Culture Documents
Chapter (5) Condition
Chapter (5) Condition
Conditional Statement
Comparison Operators
Logical Operators
not Reverse the result, returns False if the result is true not(x>=5 and x<=10)
Conditional Statement
The if statement is used test a condition. If condition is true, statement of if block is executed
otherwise it is skipped.
else: elif(condition2):
statements statements
elif(condition3):
statements
else:
statments
str="Welcome!"
if str!="" :
if(num%2==0):
else:
if(num<0):
elif(num>0):
else:
else:
if(mark1<40 or mark2<40):
else:
Exercise
• Accept the student’s mark and check this mark. If mark is between 100 and 40, should be
display “Pass the Exam”. If mark is between 39 and 0, should be display “Fail the Exam”.
Otherwise, display “Invalid the Mark”.
• Write a python program to accept user name and password from user and to check user name
and password using two-way conditional statement and display it.