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
14
+
console.log(formatTimeDisplay(61))
15
+
16
+
// You will need to play computer with this example - use the Python Visualizer 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
21
-
22
-
// Call formatTimeDisplay with an input of 61, now answer the following:
23
+
// ans: 3 times
24
+
// Call formatTimeDisplay with an input of 61, now answer the following:
23
25
24
26
// b) What is the value assigned to num when pad is called for the first time?
25
-
// =============> write your answer here
26
-
27
-
// c) What is the return value of pad is called for the first time?
28
-
// =============> write your answer here
27
+
// =============> write your answer here : 0
28
+
// c) What is the return value of pad is called for the first time?
29
+
// =============> write your answer here value : 00
29
30
30
31
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
31
-
// =============> write your answer here
32
-
32
+
// =============> write your answer here : 1 When formatTimeDisplay(61) is called, the value 61 is passed as the argument to seconds.
33
+
// Then remainingSeconds is calculated using seconds % 60, which gives 1.
34
+
// The last call to pad is pad(remainingSeconds).
35
+
// Since remainingSeconds is 1, the value assigned to num in the last call is 1.
33
36
// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
34
-
// =============> write your answer here
37
+
// =============> write your answer here : 01 When formatTimeDisplay(61) is called, the value 1 is passed to pad during the last call because remainingSeconds equals 1.
38
+
// Inside the pad function:
39
+
// The number 1 is converted to a string.
40
+
// padStart(2, "0") ensures the string has at least two characters.
41
+
// Since "1" has only one character, a "0" is added to the beginning.
42
+
// So "1" becomes "01".
43
+
// This ensures the time format follows the 00:00:00 structure.
0 commit comments