0% found this document useful (0 votes)
4 views4 pages

Format 1

The document contains a series of questions and answers regarding the Python calendar and time modules. It covers functions like calendar.monthrange, calendar.prcal, calendar.setfirstweekday, and various time functions, detailing their outputs and parameters. The document serves as a quiz or study guide for understanding how to work with dates and calendars in Python.

Uploaded by

gautamchandan25
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Format 1

The document contains a series of questions and answers regarding the Python calendar and time modules. It covers functions like calendar.monthrange, calendar.prcal, calendar.setfirstweekday, and various time functions, detailing their outputs and parameters. The document serves as a quiz or study guide for understanding how to work with dates and calendars in Python.

Uploaded by

gautamchandan25
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

What does calendar.monthrange(2025, 7) return?A. A tuple with two valuesB.

The
number of days in July 2025C. A string representation of July 2025D. The weekday
July 2025 starts onAnswer: A, B, D

Which statements about calendar.monthrange(year, month) are true?A. The first value
is between 0 and 6B. The second value is always 30 or 31C. The first value
represents the weekday the month starts onD. The second value represents the number
of days in the monthAnswer: A, C, D

What does the c parameter in calendar.TextCalendar.formatyear control?A. The number


of columns in the outputB. The spacing between month columnsC. The width of date
columnsD. The number of months per rowAnswer: B

What are possible values returned by calendar.monthrange(2025, 7)[0]?A. 0 (Monday)


B. 6 (Sunday)C. 7 (Beyond Sunday)D. 4 (Thursday)Answer: A, B, D

What does calendar.prcal(2025) do?A. Prints a calendar for 2025 to the consoleB.
Returns a list of all days in 2025C. Sets the first weekday to SundayD. Calculates
leap days in 2025Answer: A

How many days does February 2025 have?A. 28B. 29C. 30D. 31Answer: C

What does the l parameter in calendar.TextCalendar.formatyear control?A. The number


of lines per weekB. The number of months per rowC. The spacing between columns
Answer: A

Which parameters can be used in calendar.TextCalendar.formatyear?A. w (width of


date columns)B. l (lines per week)C. c (spacing between columns)D. m (months per
row)Answer: A, B, C, D

What is the output of calendar.monthrange(2024, 2)?A. (5, 28)B. (5, 29)C. (6, 28)D.
(6, 29)Answer: B

Which statements about calendar.prcal(year) are correct?A. It prints a full-year


calendarB. It uses the default first weekday settingC. It returns a string valueD.
It can be customized with parameters like w, l, c, and mAnswer: A, B, D

What does calendar.prmonth(2025, 6) do?A. Prints the year calendarB. Prints the
month calendarC. Returns the month calendar as a stringD. Converts the month
calendar to HTMLAnswer: B

What type does calendar.prmonth(2025, 6) return?A. NoneTypeB. strC. intD. tuple


Answer: A

What does calendar.setfirstweekday modify?A. The year calendarB. The format of the
dateC. The start of the week in the calendar displayD. The number of days in a
monthAnswer: C

What range of values can be passed to calendar.setfirstweekday()?A. 0 to 6B. 1 to 7


C. 0 to 12D. 1 to 6Answer: A

What is returned by time.time()?A. Unix timestampB. Month numberC. Weekday numberD.


Current date and timeAnswer: A

What type does time.time() return?A. datetime.dateB. strC. intD. floatAnswer: C

Which of these function calls is correct for printing May 2024?A.


calendar.prmonth(2024, 5)B. calendar.prmonth(5, 2024)C. calendar.prmonth(2024)D.
calendar.prmonth(5)Answer: A
What happens if you call calendar.setfirstweekday(7)?A. It sets the first weekday
to SundayB. It throws an error because the valid range is 0 to 6C. It starts the
week on a random weekdayD. It sets Monday as the first weekdayAnswer: B

What is the purpose of w in calendar.TextCalendar.formatyear()?A. To set the week


width and line length for printingB. To define the first day of the weekC. To
specify the number of months to printD. To select the calendar formatAnswer: A

Is calendar.setfirstweekday(3) valid?A. Yes, 3 represents WednesdayB. No, the valid


range is 0 to 6C. Yes, but only in a non-Gregorian calendarD. No, it will throw an
errorAnswer: A

What does the function calendar.prmonth(year, month, w=0, l=0) do?A) Prints the
year calendarB) Prints the month calendarC) Returns the month calendar as a string
D) Converts the month calendar to HTMLAnswer: B

What is the return type of calendar.prmonth(2024, 4)?A) NoneTypeB) strC) intD)


tupleAnswer: A

Which of the following does calendar.setfirstweekday(weekday) affect?A) The year


calendarB) The format of the dateC) The start of the week in the calendar displayD)
The number of days in a monthAnswer: C

What is the valid range for the weekday argument in


calendar.setfirstweekday(weekday)?A) 0 to 6B) 1 to 7C) 0 to 12D) 1 to 6Answer: A

What does calendar.timegm(tuple) return?A) Unix timestampB) Month numberC) Weekday


numberD) Current date and timeAnswer: A

What is the output type of calendar.timegm((2024, 4, 1, 12, 0, 0, 0, 0, 0))?A)


datetime.dateB) strC) intD) floatAnswer: C

How do you call calendar.prmonth() to print the calendar for May 2024?A)
calendar.prmonth(2024, 5)B) calendar.prmonth(5, 2024)C) calendar.prmonth(2024)D)
calendar.prmonth(5)Answer: A

What happens if you call calendar.setfirstweekday(7)?A) It sets the first weekday


to SundayB) It throws an error because the valid range is 0 to 6C) It starts the
week on a random weekdayD) It sets Monday as the first weekdayAnswer: B

What is the purpose of the w and l parameters in calendar.prmonth(year, month, w=0,


l=0)?A) To set the week width and line length for printingB) To define the first
day of the weekC) To specify the number of months to printD) To select the calendar
formatAnswer: A

Can you set calendar.setfirstweekday(3) to start the week on Wednesday?A) Yes, 3


represents WednesdayB) No, the valid range is 0 to 6C) Yes, but only in a non-
Gregorian calendarD) No, it will throw an errorAnswer: A

What is the result of calling calendar.timegm() without arguments?A) Returns the


current Unix timestampB) Throws an error because a tuple is requiredC) Returns None
D) Returns today's date in Unix timestamp formatAnswer: B

How does calendar.prmonth() handle months with less than 7 days?A) It prints a
blank monthB) It adjusts the display automaticallyC) It will not print the monthD)
It throws an errorAnswer: B

What does calendar.timegm() accept as input?A) A time tuple in time.gmtime() format


B) A string containing a dateC) A timestampD) A datetime objectAnswer: A

What happens when you call calendar.setfirstweekday(0)?A) It sets Sunday as the


first day of the weekB) It sets Monday as the first day of the weekC) It throws an
error because 0 is not validD) It sets Saturday as the first day of the weekAnswer:
A

When would you use calendar.timegm()?A) To convert a datetime.date object to a Unix


timestampB) To set the first day of the weekC) To print the calendar for a monthD)
To convert a time.gmtime() result to a Unix timestampAnswer: D

How does calendar.setfirstweekday(6) affect the calendar output?A) It starts the


week on SaturdayB) It starts the week on SundayC) It sets Monday as the first day
of the weekD) It causes the calendar to print incorrectlyAnswer: A

Can calendar.prmonth() print a calendar for a month in the future, like May 2030?A)
Yes, it can print any month in the futureB) No, it only works for current or past
monthsC) Yes, but it will print errors for future monthsD) No, it throws an error
Answer: A

What happens if you pass calendar.prmonth(2024, 2, w=10)?A) The calendar will not
print correctly because w cannot be greater than 6B) It prints the month, but w
will have no effectC) It will print the month calendar with increased widthD) It
will throw an errorAnswer: C

What does calendar.setfirstweekday(1) do?A) It sets Sunday as the first day of the
weekB) It sets Monday as the first day of the weekC) It throws an errorD) It has no
effectAnswer: B

What is the correct syntax to print a calendar for December 2025 using
calendar.prmonth()?A) calendar.prmonth(2025, 12)B) calendar.prmonth(12, 2025)C)
calendar.prmonth(2025)D) calendar.prmonth(12)Answer: A

What does calendar.weekday(2024, 4, 1) return?A) 0 (Monday)B) 1 (Tuesday)C) 6


(Sunday)D) 4 (Thursday)Answer: A

What will calendar.monthrange(2024, 2) return?A) (3, 29)B) (3, 28)C) (3, 30)D) (3,
29)Answer: A

How do you get a matrix representation of a month using the calendar module?A)
calendar.matrix(2024, 4)B) calendar.monthcalendar(2024, 4)C) calendar.grid(2024, 4)
D) calendar.array(2024, 4)Answer: B

What does calendar.month(2024, 4) return?A) Prints the month calendarB) Returns a


string containing the month calendarC) Returns a list of weeks in the monthD)
Returns the number of days in the monthAnswer: B

What is the output of calendar.weekheader(3)?A) 'Sun Mon Tue Wed Thu Fri Sat'B) 'Su
Mo Tu We Th Fr Sa'C) 'Sun Mo Tue Wed Thu Fri Sat'D) 'Sun Tue Thu Sat Mon Wed Fri'
Answer: B

Which function returns the weekday for a given date?A) calendar.firstweekday()B)


calendar.weekday(year, month, day)C) calendar.monthrange(year, month)D)
calendar.getweekday(year, month, day)Answer: B

What will calendar.calendar(2025) do?A) Return the entire calendar of 2025 as a


stringB) Print the entire calendar of 2025C) Return a list containing each month of
2025D) Display a pop-up calendarAnswer: A
What does calendar.HTMLCalendar().formatyear(2025, 4) do?A) Generates an HTML
representation of the year calendar with 4 columnsB) Prints a plain text calendar
for the yearC) Returns the month names in HTML formatD) Converts the year to an
HTML tableAnswer: A

Which of these statements about calendar.weekday(2025, 1, 1) is correct?A) It


returns the number of weeks in January 2025B) It returns the weekday for January 1,
2025C) It prints the calendar for January 2025D) It sets the first weekday to
MondayAnswer: B

What will calendar.isleap(2028) return?A) TrueB) FalseC) NoneD) 0Answer: A

What will time.gmtime(0) return?A) The current UTC timeB) The struct_time for the
Unix epoch (January 1, 1970, 00:00:00 UTC)C) A timestamp in secondsD) NoneAnswer: B

What does time.localtime(time.time()) do?A) Returns the current time in UTCB)


Returns the current local time as a struct_timeC) Pauses execution for a secondD)
Converts a string time to a timestampAnswer: B

What is the output type of time.strftime("%Y-%m-%d")?A) intB) strC) tupleD)


datetimeAnswer: B

Which function converts a struct_time to a timestamp?A) time.totimestamp()B)


time.timegm()C) time.strftime()D) time.mktime()Answer: D

What does time.sleep(3) do?A) Pauses execution for 3 secondsB) Returns the time
after 3 secondsC) Returns the system’s uptimeD) Converts 3 seconds into a timestamp
Answer: A

What will time.ctime(1712200000) return?A) A Unix timestampB) A formatted date-time


stringC) A struct_time objectD) A tuple containing year, month, and dayAnswer: B

What is the default argument for time.localtime()?A) time.time()B) 0C) NoneD) "now"
Answer: A

What does time.perf_counter() measure?A) The system’s current timestampB) The


number of CPU cycles since startupC) A high-resolution performance counterD) The
time taken to execute the last functionAnswer: C

What does time.asctime(time.localtime()) return?A) A string representation of the


current local timeB) The Unix timestamp of the current timeC) The UTC offset of the
current timezoneD) A datetime objectAnswer: A

How do you get the number of seconds since the Unix epoch?A) time.unix_seconds()B)
time.timestamp()C) time.time()D) time.epoch_seconds()Answer: C

What does the c parameter in calendar.TextCalendar.formatyear control?A) The number


of columns in the outputB) The spacing between month columnsC) The width of date
columnsD) The number of months per rowAnswer: B

You might also like