write a program in Python to display your name ,age ,DOB , class and aim in life
Answers
The answer to this question can be given as:
Program:
import datetime #import package
name=input("Enter your name :") #input name
age=int(input("Enter your age : ")) #input age
year =int(input('Enter your birth year :')) #input year
month =int(input('Enter your birth month :')) #input month
day =int(input('Enter your birth day :')) #input day
dob = datetime.date(year, month, day) # calculate date.
cl=input("Class : ") #input Class
aim_in_life=input("Enter your air of life :") #input aim in life
# print values.
print('Name :',name)
print('Age :',age)
print('DOB :',dob)
print('Class :',cl)
print('Aim in life :',aim_in_life)
Output:
Enter your name: xxx
Enter your age: 19
Enter your birth year: 1998
Enter your birth month: 11
Enter your birth day: 02
Class: 12
Enter your air of life: xxx
Name : xxx
Age: 19
DOB: 1998-11-02
Class: 12
Aim of life: xxx
Explanation:
In the above python program, we firstly take input values from the user and print its values. The description of the program can be given as:
- In the python program first, we import datetime package for date input.
- In the next line, we define a variable that is name, age, year, day, month, dob, cl, and aim_in_life.
- Except for the dob variable we use input function for all variables. The input function is used for taking input from the user.
- In the variable age, month, date, and year we use the int that convert a string value to integer type.
- In the dob function, we use the date function for calculating the date.
- To print all the values we use the print function.
Learn more:
- Input data from user: https://brainly.in/question/9034835