Problem Description: Write a Python program that uses the datetime library to display the current date and time in the format YYYY-MM-DD HH:MM:SS
.
Sample Input: No input required.
Expected Output:2023-04-05 14:30:45
(Note: Output will vary based on the current date and time.)
Problem Description: Create a program that calculates a person's age based on their birthdate entered by the user. The birthdate should be input in the format YYYY-MM-DD
.
Sample Input:2000-01-01
Expected Output:23
years old (Note: Output will vary based on the current date and the input date.)
Problem Description: Write a Python script that calculates the number of days from the current date until the next New Year's Day.
Sample Input: No input required.
Expected Output:88
days until New Year (Note: Output will vary based on the current date.)
Problem Description: Ask the user to enter their birthdate in the format YYYY-MM-DD
, and then display the day of the week they were born on.
Sample Input:2000-01-01
Expected Output:Saturday
Problem Description: Write a Python program that asks the user to enter a date in the format YYYY-MM-DD
and a number of days to add to this date. The program should then display the new date after adding the specified days.
Sample Input:
Date: 2023-01-01
Days to add: 30
Expected Output:2023-01-31
Problem Description: Create a program that calculates the difference in days between two dates entered by the user. Both dates should be input in the format YYYY-MM-DD
.
Sample Input:
First date: 2023-01-01
Second date: 2023-01-31
Expected Output:30 days
Problem Description: Ask the user to enter a date in the format YYYY-MM-DD
. The program should then display the name of the month for that date.
Sample Input:2023-03-15
Expected Output:March
Problem Description: Write a program that asks the user to enter a year, then prints the date of the first Monday of that year.
Sample Input:2023
Expected Output:2023-01-02
Problem Description: Write a Python program that asks the user to enter a year and a month (as numbers), then prints the last day of that month.
Sample Input:
Year: 2023
Month: 2
Expected Output:2023-02-28
Problem Description: Create a program that calculates the number of Mondays (or any specified weekday) in a given month and year entered by the user.
Sample Input:
Year: 2023
Month: 3
Weekday: Monday
Problem Description: Write a Python script that asks the user for their birthdate and calculates their age in days as of today.
Sample Input:2000-01-01
Expected Output:Approximately 8505 days old
(Note: Output will vary based on the current date.)
Problem Description: Create a program that asks the user for a time in the format HH:MM
and a number of hours to add. The program should then print the new time.
Sample Input:
Time: 14:30
Hours to add: 5
Expected Output:19:30