my_string = "I am a string"
my_num = 5
print my_string, "and I'm a", my_num
for
loop along a list¶print range(10)
for num in range(10):
print num
for
loop¶for item in ['dog', 'cat', 'pig']:
print item
if
statements)¶if my_num == 5:
print "it's a 5!"
else:
print "it's not a 5!"
if 5<2:
print 'yes indeed'
elif 10<2:
print 'this is true too!'
Predict what each of these statements will return. Then check.
print 's'==True
print 1==True
print 0==True
print True==False
print (True or False)==True
print print==True
while
loop¶another_num=5
while another_num <= 5 and another_num>0:
print "I'm a ", another_num, "and I'm less than or equal to 5!"
another_num -= 1
0
01
012
0123
01234
012345