Deadline: Tu 2/10/2015 at 7 AM
Refer to the Week 4 reading as necessary to complete this assignment.
line = 1 for i in range(1, 4): for j in range(1, 5): print('Line ', line, ': (', i, ', ', j, ')', sep="") line += 1Try to predict what this loop will do. Answer Questions 1-4 in your pre-lab. Then use the tutor to step through this loop and check your work.
line = 1 for i in range(1, 6): for j in range(1, 3): print('Line ', line, ': (', i, ', ', j, ')', sep="") line += 1Again, try to predict what this loop will do. Answer Questions 5-7 in your pre-lab. Then use the tutor to step through this loop and check your work.
# For Question 8 def main(): num = 5 # change this value if num == 0: num += 2 # identical to num = num + 2 print('Your value is now ', num, '.', sep="") else: num += 4 # identical to num = num + 4 print('Your value is now ', num, '.', sep="") if num > 0: num -= 4 # identical to num = num - 4 print('Your value is now ', num, '.', sep="") main()
# For Question 9 if num == 0: num += 2 print('Your value is now ', num, '.', sep="") if num < 0: num += 4 print('Your value is now ', num, '.', sep="") else: num -= 4 print('Your value is now ', num, '.', sep="")Answer Question 9 in your pre-lab.
# For Question 10 if num == 0: num += 2 print('Your value is now ', num, '.', sep="") elif num < 0: num += 4 print('Your value is now ', num, '.', sep="") if num > 0: num -= 4 print('Your value is now ', num, '.', sep="")Answer Question 10 in your pre-lab.
# For Question 11 if num == 0: num += 2 print('Your value is now ', num, '.', sep="") elif num < 0: num += 4 print('Your value is now ', num, '.', sep="") else: num -= 4 print('Your value is now ', num, '.', sep="")Answer Question 11 in your pre-lab.
Review your answers, and then click the Next button at the bottom of the Moodle quiz.
Once you do that, you should see something similar to this:
Click the Submit all and finish button. You MUST do this so that your
pre-lab can be graded! Once you have submitted your quiz, you should see
something similar to this at the top of your Moodle window. The important part is that the State shows up as Finished.