1
2
3
4
5
|
temperature = float ( input ( "Temperature: " ) if temperature > 30 : print ( "It is hot outside." ) else : print ( "It is not hot out." ) |
1
2
3
4
5
6
7
|
user_input = input ( "A cherry is a: " ) print ( "A. Dessert topping" ) print ( "B. Desert topping" ) if user_input = = "A" : print ( "Correct!" ) else : print ( "Incorrect." ) |
1
2
3
4
5
|
x = =
input ( " x = " ))
if x > = 0 : print ( "x is positive." ) else : print ( "x is not positive." ) |
1
2
3
|
x = input ( "Enter a number: " ) if x = 3 print ( "You entered 3" ) |
1
2
3
|
x = input ( "How are you today?" ) if x = = "Happy" or "Glad" : print ( "That is good to hear!" ) |
1
2
3
4
5
6
7
8
9
10
|
x = 5 y = x = = 6 z = x = = 5 print ( "x=" , x) print ( "y=" , y) print ( "z=" , z) if y: print ( "Fizz" ) if z: print ( "Buzz" ) |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
x = 5 y = 10 z = 10 print (x < y) print (y < z) print (x = = 5 ) print ( not x = = 5 ) print (x ! = 5 ) print ( not x ! = 5 ) print (x = = "5" ) print ( 5 = = x + 0.00000000001 ) print (x = = 5 and y = = 10 ) print (x = = 5 and y = = 5 ) print (x = = 5 or y = = 5 ) |
1
2
3
4
5
6
7
8
9
|
print ( "3" = = "3" ) print ( " 3" = = "3" ) print ( 3 < 4 ) print ( 3 < 10 ) print ( "3" < "4" ) print ( "3" < "10" ) print ( ( 2 = = 2 ) = = "True" ) print ( ( 2 = = 2 ) = = True ) print ( 3 < "3" ) |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
print ( "Welcome to Bank of Monastiraki!" ) print ( "A. Banker" ) print ( "B. Carpenter" ) print ( "C. Farmer" ) user_input = input ( "What is your occupation? " ) if user_input = A: money = 100 else if user_input = B: money = 70 else if user_input = C: money = 50 print ( "Great! you will start the game with" , money, "dollars." ) |