#Conditionals statements in python#'=' conditionals statements
a =123
b =123if(a==b):print('True')#<, > conditionals statements
a =2
b =45if(a<b):print('A is smaller than B')
can_do =True
can_do1 =Trueif can_do:print("we can do it")elif can_do1:print("we can do it but the second time")else:print("we cant do it")#result should be (we can do it.)
x =int(input("number: "))# get number from userif x <0:print(f"{x} is less than 0!")# if x is less than 0, print x is less than 0elif x ==0:print(f"{x} is equal to 0!")# if x is equal to 0 then print x is equal to 0if x >0:print(f"{x} is more than 0!")# if x is greater than 0 print x is more than 0# yeah its me somewhatoriginal
# If the number is positive, we print an appropriate message
num =3if num >0:print(num,"is a positive number.")print("This is always printed.")
num =-1if num >0:print(num,"is a positive number.")print("This is also always printed.")
user_info =input("How may I help you?: ")if user_info =="on":print("Light is Turned Om")elif user_info =="off":print("Light is turned Off")elif user_info =="status":input("All are Good.What do you need?: ")print("I don't have it")else:print("Shutdown processing are being Ready")#copy the code to your py script to have the results!!!
temperature =float(input('What is the temperature? '))if temperature >70:print('Wear shorts.')else:print('Wear long pants.')print('Get some exercise outside.')
can_run =True
can_run2 =Falseif can_run:print("i can run the code because can_run is true")elif can_run2:print("i can run the code if can_run2 is true")else:print("no other bool found true")#result should be (i can run the code because can_run is true
number =int(input("Enter a number from 1 to 3"))# make the user write a random number from 1 to 3if number ==1:print("You choose number 1")elif number ==2:print("You choose number 2")else:print("You choose number 3")
num =1if num ==1:print("num is 1"))elif num ==2:print("num is 2")else:print('invalid number')# output num is 1# if the conditional is true the left side of side the expression is resolved else the right side is resolvedprint("num is 2")if num ==2elseprint("num is 1")# output num is 1
usrinput =input('Type a number')if usrinput =5print('Your number is equal to 5')elif usrinput >5print('Your number is bigger than 5')elif usrinput <5print('Your number is less than 5')