if x < 10: print "x is smaller than 10"
if x > 10 and x < 20: x = x * 2 print "x was doubled, and it is now ", x
if x < 10: print "x is smaller than 10" else: print "x is larger than 10 or equals 10"
if a >= b: max = a else: max = b
# print the numbers from 1 to 10. i = 1 while i <= 10: print i # now do the same, from 10 to 1 i = 10 while i > 0: print i
# variable 'game_over' will be used to flag the end of the game. game_over = 0 while not game_over: # handle one turn of the game here. . . # somewhere, we need to decide that the game is over. if .....: game_over = 1
while true: # handle one turn of the game here. . . # somewhere, we need to decide that the game is over. if .....: break
num_string = raw_input("give me a number: ")
num_string = raw_input("give me a number: ") num = int(num_string)
num_string = int(raw_input("give me a number: "))
>>> num = int("hello") Traceback (most recent call last): File "<stdin>", line 1, in ? ValueError: invalid literal for int(): hello