Challenge: Time Calculation in Python
Task
Swipe to start coding
Imagine you are a bookkeeper, and you need to process 10
financial transactions. You've noticed that each transaction takes an average of 7
minutes, but you only have 60
minutes available.
- Calculate how many transactions you couldn't complete and assign the result to the variable
remaining_tasks
. - Calculate how many minutes would be needed to complete all
10
transactions if each takes7
minutes, and assign the result to the variablerequired_time
.
Solution
99
1
2
3
4
5
6
7
8
9
10
11
12
# Number of completed transactions
completed = 60 // 7
# Number of remaining minutes
minutes = 60 % 7
# Set the number of remaining transactions
remaining_tasks = 10 - completed
# Set the total time needed to complete all transactions
required_time = 10 * 7
# Print the results
print("The number of remaining transactions is", remaining_tasks)
print("The number of minutes needed to complete all transactions is", required_time)
Everything was clear?
Thanks for your feedback!
Section 1. Chapter 6
99
1
2
3
4
5
6
7
8
9
10
11
12
# Number of completed transactions
completed = 60 // 7
# Number of remaining minutes
minutes = 60 % 7
# Set the number of remaining transactions
remaining_tasks = ___
# Set the total time needed to complete all transactions
required_time = ___
# Print the results
print("The number of remaining transactions is", ___)
print("The number of minutes needed to complete all transactions is", ___)
Ask AI
Ask anything or try one of the suggested questions to begin our chat