1usrinput = input(">> ")
2if usrinput == "Hello":
3 print("Hi")
4elif usrinput == "Bye":
5 print("Bye")
6else:
7 print("Okay...?")
8
1#if else conditions in python
2a = "if else conditions are inportant"
3if "else" in a:
4 print("Word is in a")
5else:
6 print("word is not in a")
7
1# IF ELSE ELIF
2
3print('What is age?')
4age = int(input('number:')) # user gives number as input
5if age > 18:
6 print('go ahead drive')
7elif age == 18:
8 print('come personaly for test')
9else:
10 print('still underage')
11
1print("Welcome to Rolercoster rider")
2print()
3#taking input of your hight
4Your_hight = int(input("What is Your hight:- "))
5#if condition
6if Your_hight >= 120:
7 print("You are good to go to the roller coster")
8else:
9 print("Grow taller to go to the rolercoster")
1a = 200
2b = 33
3if b > a:
4 print("b is greater than a")
5elif a == b:
6 print("a and b are equal")
7else:
8 print("a is greater than b")
1# The if,elif,else statements check if something is True
2# example
3if 10 > 5:
4 print("Ten is greater than five")
5
6#but let's say we write
7if 10 < 5:
8 print("Ten is less than five")
9#then this condition wouldn't be true
10#so we create an "else" statement
11if 10 < 5:
12 print("Ten is less than five")
13else:
14 print("Ten is greater than five")
15
16#this will print "Ten is greater than five"
17# because in the if statement it checks if something is true
18# we wrote 'if 10 < 5' and it's not true
19# so in case the 'if' condition evaluates to false
20# it executes another command
21
22#now, the 'elif' statement
23# this will check for another thing after the if statement
24#example
25if 10 < 5:
26 print("Ten is less than five")
27elif 10 > 5:
28 print("Ten is greater than five")
29# here we check if 10 is less than five
30# then the statement evaluated to false because 10 is greater than 5
31# so the program checked with the 'elif' (that means 'Else if')
32# if the statement was true, and it was so it executed the command
33
34#we can add as many elif statements as we want in our program
35# but they always need to start with an 'if' statement
36# and we can make only ONE 'else' statement at the end
37# let's add an 'else' statement to the previous program
38if 10 < 5:
39 print("Ten is less than five")
40elif 10 > 5:
41 print("Ten is greater than five")
42else:
43 print("Ten isn't greater or less than five")
44# in this case it will print 'Ten is greater than five'
45# hope this helped