DEV Community

Cover image for Day 5: Writing our first program in python with home🧡work
aryan015
aryan015

Posted on • Edited on

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

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay