Professional Documents
Culture Documents
Repane Removalexam
Repane Removalexam
1. Given a template that pre-defines three variables hours, minutes and seconds, write an
assignment statement that updates the variable total_seconds to have a value corresponding to
the total number of seconds for hours, minutes and seconds.
hours = 1
minutes = 58
seconds = 32
2. Given the pre-defined variables name (a string) and age (a number), write an assignment
statement that defines a variable statement whose value is the string "% is % years old." where
the percents should be replaced by name and the string form of age.
4. Write a Python function is_lunchtime that takes as input the parameters hour (an integer in the
range [1, 12][1,12]) and is_am (a Boolean “flag” that represents whether the hour is before noon).
The function should return True when the input corresponds to 11am or 12pm (noon) and False
otherwise. If the problem specification is unclear, look at the test cases in the provided template.
Our solution does not use conditional statements.
def is_lunchtime(hour, is_am):
if hour = = 11 and is_am:
return True
else:
return False
res = is_lunchtime(11, True)
print(res)
print(‘=====’)
5. Given the program template below, modify the program to create a CodeSkulptor frame that
opens a 200×100-pixel frame with the title "My second frame". Remember to use the Docs to
determine the correct syntax for the necessary SimpleGUI calls.
message = “My second frame”
def click_2()
print message
frame.start()