10.1. Python Practice - Flow Control
10.1. Python Practice - Flow Control
if b > a:
print("b is greater than a")
Output
if b > a:
print("b is greater than a")
Output
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
Output
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
else:
print("a is greater than b")
Output
if b > a:
print("b is greater than a")
else:
print("b is not greater than a")
Output
Output
if flag==True:
print("Welcome")
print("To")
print("Python programming language" )
Output
if flag==True:
print("Welcome")
print("To")
print("Python programming language" )
Output
if (i < 15):
print ("i is smaller than 15")
print ("i'm in if Block")
else:
print ("i is greater than to 15")
print ("i'm in else Block")
if (i < 15):
print ("i is smaller than 15")
if (i < 12):
print ("i is smaller than 12 too")
else:
print ("i is greater than 15")
Output
elif y>z:
print("y is greater than remaining two values")
else:
print("z is greater than remaining two values ")
Output
i = int(a)
elif i<35:
print("Sorry boss, you failed")
Output
Output
if balance < 0:
print("Balance is in negative mode please add funds now
or you will be charged a penalty.")
Output
Output
print(isinstance(x, int))
print(isinstance(x, str))
Output
print(isinstance(name, str))
print(isinstance(name, int))
Output
if isinstance(x, int):
print("integer data type")
else:
print("Its other type")
Output
if isinstance(x, str):
print("string data type")
else:
print("It is an integer type")
Output
if isinstance(name, str):
print("string data type")
else:
print("It is other type")
Output
if isinstance(xyz, int):
print("integer data type")
else:
print("It is string data type")
Output
if answer == "Yes":
print("Welcome to Python sessions by Daniel, please don
't sleep")
else :
print("I guess you are not student of Daniel.")
print("Thanks!")
Output
if username in allowed_users:
print("Access granted, Enjoy Guru :")
else:
print("Sorry Boss, access denied: Contact Admin team.
Namaskaar")
Output
if guess == number:
print("Congratulations Dude, you guessed it but no prizes
:) ")
else:
print('No, it is a little lower than guessed number')
Output
if x < 10:
print("Good morning")
elif x<12:
print("Soon time for lunch")
elif x<18:
print("Good day")
elif x<22:
print("Good evening")
else:
print("Dude, please Buy clock and learn timings, Good
day")
Output
else:
print("Congratulation Dude, you have successfully failed")
Output
else:
print("Congratulation Dude, you have successfully failed")
Output
print("Thank you")
Output
while running:
guess = int(input('Please guess number between 1 to 10 :
'))
if guess == number:
print('Congratulations Dude, you guessed it but no
prizes :)')
running = False
else:
print('No, it is a little lower than that.')
else:
print('The while loop is over.')
Output
Output
Output
Output
Program
Accepts a sequence of lines and print those lines by using list,
when entered blank line then program terminates
Name demo33.py
lines = []
print(lines)
while True:
l = input()
if l:
lines.append(l)
else:
break
print(lines)
Output
Output
Output
else:
print(l, " is a consonant.")
Output
if len(l)==1:
else:
print(l, " is a consonant.")
else:
print("Invalid input")
Output
if month_name == "February":
print("No. of days: 28/29 days")
else:
print("Any month name like", month_name, "?")
Output
for i in range(1,11):
print(n, 'x', i,'=',n*i)
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output
Output