In: Computer Science
Python Review in class Worksheet
38 seconds, light stays steady, 95 seconds light stays steady, Dark for 19 seconds
The flickers change
60 seconds flickers, light stays steady, 160 seconds flickers light stays steady, dark 20 seconds
The flickers change
54 seconds flickers, light stays steady, 126 seconds flickers light stays steady, dark 18 seconds
The flickers change
11 seconds flickers, light stays steady, 111 seconds flicker light stays steady, dark ___ seconds
The flickers change
28 seconds flickers, light stays steady, 70 seconds flickers light stays steady, dark __ seconds
The flickers change
21 seconds flickers, light stays steady, 56 seconds flickers light stays steady, dark 7 seconds
The flickers change
5 seconds flickers, light stays steady, 50 seconds flickers light stays steady, dark __ seconds
The flickers change
18 seconds flickers, light stays steady, 180 seconds flickers light stays steady, dark __ seconds
The flickers change
60 seconds flickers, light stays steady, 160 seconds flickers light stays steady, dark 20 seconds
The flickers change
40 seconds flickers, light stays steady, 72 seconds flickers light stays steady, dark __ seconds
The flickers change
36 seconds flickers, light stays steady, 27 seconds flickers light stays steady, dark 9 seconds
The flickers change
28 seconds flickers, light stays steady, 70 seconds flickers light stays steady, dark 14 seconds
The flickers change
21 seconds flickers, light stays steady, 56 seconds flickers light stays steady, dark __ seconds
The flickers change
38 seconds, light stays steady, 95 seconds light stays steady, Dark for 19 seconds
A terrible sizzling is heard and the smell of electrical smoke, and all the lights go out and stay that way.
Figure out the pattern, then write a python program to calculate the missing Darks and then print out the result of the code.
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Raw_code:
def dark(light1, light2):
remainder = light2 % light1
difference = light1 - remainder
print("{0:1d} seconds flickers, light stays steady,"
" {1:1d} seconds flickers, light stays steady".format(light1,
light2), end = " ")
if remainder == difference:
print("dark :", difference)
elif remainder < difference:
print("dark :", remainder)
elif difference < remainder:
print("dark: ", difference)
dark(38, 95)
dark(60, 160)
dark(54, 126)
dark(11, 111)
dark(28, 70)
dark(21, 56)
dark(5, 50)
dark(18, 180)
dark(60, 160)
dark(40, 72)
dark(36, 27)
dark(28, 70)
dark(21, 56)
dark(38, 95)