Ad Code

Responsive Advertisement

Basic Python Program - 46

Question 46: Write a Python program that will display Calendar of given month using Calendar Module.
Download hole Program / Project code, by clicking following link:
What is the output of the following program?
import random
import datetime
from datetime import date
import time
print time.time()
print date.fromtimestamp(454554)

It appears that you're using Python 2 syntax. In Python 2, you don't need parentheses when calling functions. In Python 3, you should use parentheses when calling functions.
Here's the corrected Python 2 code:
import datetime
from datetime import date
import time
print time.time()
print date.fromtimestamp(454554)


The corrected Python 2 code would produce the following output:
# This output will vary based on the current time.
# Example outputs:
1634721419.63
1970-01-06
Here's what each line does:
  1. time.time(): This prints the current timestamp in seconds since the epoch (January 1, 1970). The output will be the current timestamp, so it will vary every time you run the program.
  2. date.fromtimestamp(454554): This prints the date corresponding to the timestamp 454554 seconds since the epoch. In this example, it corresponds to January 6, 1970, which is the date 454554 seconds after the epoch.
Programming Code:
Following code write in: BP_P46.py
# Python Program

# Display Calendar of given month using Calendar Module

# import Module

import Calendar_Module

year = int(input("Enter Year: "))
month = int(input("Enter Month of Year: "))

print(f"Given {year} year and {month} month ")

print("Calendar is: ")

cal = Calendar_Module.Calendar_365(year=year, month=month)
cal.show()

# Thanks for Reading.
Output:

Post a Comment

0 Comments

Ad Code

Responsive Advertisement