In a school a class teacher wants to estimate age of the students in years, months and days. Date of birth will be given as input by the user in the format years-months-days. write a python program to estimate age of the student in the asked format. (Example: If the input is "1997-10-12", then the output of the program should be "26 years, 1 months, 13 days " )Input Format:Years-months-daysOutput Format:total years, total months, total days
Question
In a school a class teacher wants to estimate age of the students in years, months and days. Date of birth will be given as input by the user in the format years-months-days. write a python program to estimate age of the student in the asked format. (Example: If the input is "1997-10-12", then the output of the program should be "26 years, 1 months, 13 days " )Input Format:Years-months-daysOutput Format:total years, total months, total days
Solution
Sure! Here's a Python program that estimates the age of a student in years, months, and days based on their date of birth:
from datetime import datetime
# Get the date of birth from the user
dob = input("Enter your date of birth (YYYY-MM-DD): ")
# Convert the date of birth string to a datetime object
dob_date = datetime.strptime(dob, "%
Similar Questions
7.Question 7Consider this code:12age1 = input("How old are you? ")age2 = input("How old is your best friend? ")The user enters the ages in years as whole numbers (e.g., 2). Select the code fragment(s) that print the sum of the ages. Be sure to use Python 3.1 pointprint(int(age1) + int(age2))print(int(age1) + int(age2))print(age1 + age2)print(age1 + age2)print(str(int(age1 + age2)))print(str(int(age1 + age2)))x = int(age1)x = int(age1)y = int(age2)y = int(age2)print(str(x + y))print(str(x + y))
shu wants to create a program that asks users to input their birthdates, including the day, month, and year. The program should then display the entered birthdate in the format "DD/MM/YYYY."Write a program to assist Ishu in achieving this task.Input format :The input consists of three space-separated integer values, representing the user's birthdate(day, month, and year).Output format :The output displays the user's birthdate in the format "Your birthday is on " followed by the formatted date DD/MM/YYYY.
Choose the code to assign your age into age variable?age=45print(age)age="45 "print(age)age=str(99)print(age)None of the above
Could not pasteHailey is curious about the ages of her friends, Alex and Bob. She knows the sum of their ages and wants to determine their individual ages. The hint is that Alex is 5 years older than Bob. Can you help her create a program using pointers that calculates and prints the ages of Alex and Bob? Input format : The input consists of an integer N, representing the sum of Alex and Bob's ages. Output format : The first line of output prints the age of Alex. The second line prints the age of Bob. Refer to the sample output for formatting specifications. Code constraints : 1 ≤ N ≤ 100 Sample test cases : Input 1 : 45 Output 1 : Alex is 25 years old. Bob is 20 years old. Input 2 : 91 Output 2 : Alex is 48 years old. Bob is 43 years old.
Write a python code to find the year of joining of a student in vit from his/ her registration number. The first two digits of the registration number define the last two digits of the year. Concatenate it to 20 and find the whole year.Witout using function.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.