#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.)
variable_name =input("y/n? >> ")if variable_name =="y":print("That's good! :) ")# note the double equal signs. only a single equal sign will receive a Syntax error blah blah blah message.elif variable_name =="n":print("That's bad! :( ")else:print("You blow up for not following my instructions. Detention forever and get lost!")
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!!!
Num1=float
Num2=float
Ans=float
operator=intprint("These are the following operations available:,1for addition.2for subtraction.3for multiplication.4for division.")
operator =int(input("Enter the operator you wish to use"))
Num1 =float(input("Please enter your first number:"))
Num2 =float(input("Please enter your second number:"))if operator ==1:
Ans == Num1 + Num2
else:if operator ==2:
Ans == Num1 - Num2
else:if operator ==3:
Ans == Num1 * Num2
else:if operator ==4:
Ans == Num1 / Num2
print("Your answer is: %f.2", Ans)
temperature =float(input('What is the temperature? '))if temperature >70:print('Wear shorts.')else:print('Wear long pants.')print('Get some exercise outside.')
defe(x):if x =="Sunny"and x =="sunny":print('Remember your sunglasses!')elif x =="Rainy"and x =="rainy":print('Do not forget your umbrella!')elif x =='Thunderstorm'or x =='thunderstorm'or x =='Stormy'or x =='stormy':print('Stay Home!')
x =input('What is the weather?')
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
person =input("Nationality? ")if person =="french"or person =="French":print("Préférez-vous parler français?")if person =="italian"or person =="Italian":print("Preferisci parlare italiano?")
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")
water =input('Does your creature live underwater?')if water =='yes':print('Your creature lives underwater')else:print('Your creature does not live underwater')
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')
boolean1 =(1!=1)
boolean2 =(2+2==5)
boolean3 =(1==1)if(boolean1):print("Boolean one is true")elif(boolean2):print("Boolean two is true")else:print("Boolean three may, or may not be true")