Skip to main content
edited body
Source Link
Csarg
  • 363
  • 1
  • 4
  • 16

This is the code I have for measuring how long it took the user to complete the program:

start_time = time.time() # Sits at the top of my code print("%f seconds" % (time.time() - start_time)) # Goes at the bottom of my code 

My question is, how do I round the output of this to one decimal place? For example, if my output was 3.859639 seconds how would I present this like: 3.48 Secounds?

This is the code I have for measuring how long it took the user to complete the program:

start_time = time.time() # Sits at the top of my code print("%f seconds" % (time.time() - start_time)) # Goes at the bottom of my code 

My question is, how do I round the output of this to one decimal place? For example, if my output was 3.859639 seconds how would I present this like: 3.4 Secounds?

This is the code I have for measuring how long it took the user to complete the program:

start_time = time.time() # Sits at the top of my code print("%f seconds" % (time.time() - start_time)) # Goes at the bottom of my code 

My question is, how do I round the output of this to one decimal place? For example, if my output was 3.859639 seconds how would I present this like: 3.8 Secounds?

added 8 characters in body
Source Link
AChampion
  • 30.5k
  • 4
  • 63
  • 79

This is the code I have for measuring how long it took the user to complete the program: start_time = time.time() # Sits at the top of my code print("%f seconds" % (time.time() - start_time)) # Goes at the bottom of my code

start_time = time.time() # Sits at the top of my code print("%f seconds" % (time.time() - start_time)) # Goes at the bottom of my code 

My question is, how do I round the output of this to one decimal place? For example, if my output was 3.859639 seconds how would I present this like: 3.4 Secounds?

This is the code I have for measuring how long it took the user to complete the program: start_time = time.time() # Sits at the top of my code print("%f seconds" % (time.time() - start_time)) # Goes at the bottom of my code

My question is, how do I round the output of this to one decimal place? For example, if my output was 3.859639 seconds how would I present this like: 3.4 Secounds?

This is the code I have for measuring how long it took the user to complete the program:

start_time = time.time() # Sits at the top of my code print("%f seconds" % (time.time() - start_time)) # Goes at the bottom of my code 

My question is, how do I round the output of this to one decimal place? For example, if my output was 3.859639 seconds how would I present this like: 3.4 Secounds?

Source Link
Csarg
  • 363
  • 1
  • 4
  • 16

Python: Rounding output of the time module

This is the code I have for measuring how long it took the user to complete the program: start_time = time.time() # Sits at the top of my code print("%f seconds" % (time.time() - start_time)) # Goes at the bottom of my code

My question is, how do I round the output of this to one decimal place? For example, if my output was 3.859639 seconds how would I present this like: 3.4 Secounds?