Skip to content

Commit f7ff880

Browse files
restore accidentally deleted files
1 parent db4dc5d commit f7ff880

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
function pad(num) {
2+
let numString = num.toString();
3+
while (numString.length < 2) {
4+
numString = "0" + numString;
5+
}
6+
return numString;
7+
}
8+
9+
function formatTimeDisplay(seconds) {
10+
const remainingSeconds = seconds % 60;
11+
const totalMinutes = (seconds - remainingSeconds) / 60;
12+
const remainingMinutes = totalMinutes % 60;
13+
const totalHours = (totalMinutes - remainingMinutes) / 60;
14+
15+
return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`;
16+
}
17+
18+
// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit
19+
// to help you answer these questions
20+
21+
// Questions
22+
23+
// a) When formatTimeDisplay is called how many times will pad be called?
24+
// =============> write your answer here
25+
26+
// Call formatTimeDisplay with an input of 61, now answer the following:
27+
28+
// b) What is the value assigned to num when pad is called for the first time?
29+
// =============> write your answer here
30+
31+
// c) What is the return value of pad is called for the first time?
32+
// =============> write your answer here
33+
34+
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
35+
// =============> write your answer here
36+
37+
// e) What is the return value of pad when it is called for the last time in this program? Explain your answer
38+
// =============> write your answer here

0 commit comments

Comments
 (0)