Python: System time print Python
Python Basic: Exercise-98 with Solution
Write a Python program to get system time.
Note : The system time is important for debugging, network information, random number seeds, or something as simple as program performance.
Pictorial Presentation:
Sample Solution-1:
Python Code:
# Import the 'time' module to work with time-related functions.
import time
# Print an empty line for formatting.
print()
# Get and print the current time using 'time.ctime()'.
print(time.ctime())
# Print an empty line for formatting.
print()
Sample Output:
Thu Apr 20 18:25:06 2017
Sample Solution-2:
Python Code:
import datetime
print(datetime.datetime.now())
Sample Output:
2021-06-04 08:40:11.391443
Python Code Editor:
Previous: Write a Python program to list the special variables used within the language.
Next: Write a Python program to clear the screen or terminal.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://198.211.115.131/python-exercises/python-basic-exercise-98.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics