Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Time Calculation in Python | Getting Familiar With Numbers in Python
Data Types in Python

book
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.

  1. Calculate how many transactions you couldn't complete and assign the result to the variable remaining_tasks.
  2. Calculate how many minutes would be needed to complete all 10 transactions if each takes 7 minutes, and assign the result to the variable required_time.

Solution

# 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?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 6
# 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

expand
ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt