You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit
15
17
// to help you answer these questions
16
18
17
19
// Questions
18
20
19
21
// a) When formatTimeDisplay is called how many times will pad be called?
20
22
// =============> write your answer here
23
+
// When formatTimeDisplay is called, the pad function will be called three times: once for totalHours, once for remainingMinutes, and once for remainingSeconds.
21
24
22
25
// Call formatTimeDisplay with an input of 61, now answer the following:
23
26
24
27
// b) What is the value assigned to num when pad is called for the first time?
25
28
// =============> write your answer here
29
+
// When pad is called for the first time, the value assigned to num is 0, which is the value of totalHours calculated from the input of 61 seconds.
26
30
27
31
// c) What is the return value of pad is called for the first time?
28
32
// =============> write your answer here
33
+
// The return value of pad when called for the first time is "00", because pad(0) returns "00" after padding 0 with leading zeros to make it 2 digits.
29
34
30
35
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
31
36
// =============> write your answer here
37
+
// When pad is called for the last time, the value assigned to num is 1, which is the value of remainingSeconds calculated from the input of 61 seconds.
32
38
33
39
// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
34
40
// =============> write your answer here
41
+
// The return value assigned to num when pad is called for the last time in this program is "01", because pad(1) returns "01" after padding 1 with a leading zero to make it 2 digits.
0 commit comments