My Report

Python Modules Test – 3


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. What will be the output of the following Python code if the system date is 18th June, 2017 (Sunday)?

import datetime
tday=datetime.date.today()
print(tday)

2. What will be the output of the following Python code if the system date is 18th August, 2016?

tday=datetime.date.today()
print(tday.month())

3. What will be the output of the following Python code if the system date is 18th June, 2017 (Sunday)?

tday=datetime.date.today()
print(tday.weekday())

4. What will be the output of the following Python code if the system date is: 6/19/2017

tday=datetime.date.today()
tdelta=datetime.timedelta(days=10)
print(tday+tdelta)

5. Point out the error (if any) in the code shown below if the system date is 18th June, 2017?

tday=datetime.date.today()
bday=datetime.date(2017,9,18)
till_bday=bday-tday
print(till_bday)

6. What will be the output of the following Python code if the system date is 21st June, 2017 (Wednesday)?

tday=datetime.date.today()
print(tday.isoweekday())

7. Which of the following will throw an error if used after the following Python code?

tday=datetime.date.today()
bday=datetime.date(2017,9,18)
t_day=bday-tday

8. The value returned when we use the function isoweekday() is ______ and that for the function weekday() is ________ if the system date is 19th June, 2017 (Monday).

9. What will be the output of the following Python code?

import datetime
d=datetime.date(2016,7,24)
print(d)

10. What will be the output of the following Python code?

import datetime
d=datetime.date(2017,06,18)
print(d)

 

Start practicing “1000 MCQs on Python”, and once you are ready, you can take tests on all topics by attempting our “Python Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.