Monday, November 28, 2016

Blog 29

What does this function print?

def negate(x):
    print -x

print negate(5)

Friday, November 25, 2016

Blog 28

What does this function print?

def get_number():
    return 12

x=get_number()
print x

Monday, November 21, 2016

Blog 27

What does the program below print?

for i in range(1, 11):
  print i

Wednesday, November 16, 2016

Monday, November 14, 2016

Blog 25

Look at the code below. What does it print?


x=True
y=False

if x and y:
   print "hello"
else:
   print "hi"

Wednesday, November 9, 2016

Monday, November 7, 2016

Blog 23

Tell me what this program prints.

x = 3
y = 3

while x > 3 or y < 6:
    print x
    print y
 
    x = 9 - x
    y = y + 2

Saturday, November 5, 2016

Blog 22

What does this program do?
How many times does the loop go through?
Write all the output lines. (what it prints)

x=10
while x >0:
   print x
   x = x - 3