Day 5: Writing our first program in python with home🧡work

aryan015

aryan015

Posted on July 19, 2024

Day 5: Writing our first program in python with home🧡work

index
In this blog we will cover to take input and print it on the display.

input and output in python

You can take input from the user using input function. Remember input function implicit convert input to string. If you enter number then you cannot perform operations on it.

# you can pass string param to input to display 🧡
import datetime # inbuilt module to play with dates in py
today = datetime.date.today() # datetime.date(2024, 7, 19)
current_year = today.year # 2024
print(current_year)  # This will display the current year (e.g., 2024)
# int converts string to int
DOB = int(input('Enter you age')) # 1998
# calculate your age
print(current_year - DOB) # 26
Enter fullscreen mode Exit fullscreen mode

Thank you

💖 💪 🙅 🚩
aryan015
aryan015

Posted on July 19, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related