Computer Science - Informatics Practices Class XI/XII Python Module Solved Test Part 3
Q1. Write a code to print
today’s date.
Q2. How can you separate year, month and day from current
date?
Q3. today() function belongs to __________ class of
datetime module.
Q4. Which attribute return hour from datatime object?
Q5. Which attribute return day from datatime object?
Q6. time class of datetime module holds attributes for
hours, minutes, second and microsecond. (T/F)
Q7. What is the function of now() method.
Q8. Name two methods of datatime module.
Q9. ________ attribute returns month from ____ object.
Q10. Write the code to display current date and time.
SOLUTION:
Python Module Test 3
Q1. Write a code to print today’s date.
Ans. import datetime
td=datetime.date.today()
print(td)
Q2. How can you separate year, month and day from current
date?
Ans.
import datetime
td=datetime.date.today()
print(td.year)
print(td.month)
print(td.day)
Q3. today() function belongs to __________ class of
datetime module.
Ans. date
Q4. Which attribute return hour from datatime object?
Ans. hour
Q5. Which attribute return day from datatime object?
Ans. day
Q6. time class of datetime module holds attributes for
hours, minutes, second and microsecond. (T/F)
Ans. True
Q7. What is the function of now() method.
Ans. This method returns the current date and time.
Q8. Name two methods of datatime module.
Ans. today() and now()
Q9. ________ attribute returns month from ____ object.
Ans. month, datetime
Q10. Write the code to display current date and time.
Ans.
import datetime
td=datetime.datetime.now()
print(td)
No comments:
Post a Comment