DEV Community

Hamza Hesham
Hamza Hesham

Posted on • Edited on

3 1

simple age calc using python

hello, today we will make a simple age calc using python
first we will print a statement that includes "welcome to age calc"
Alt Text
second, we will make a variable called x and assign it to an input function "please enter your birth year :\n" an convert the type of input to integer
!NOTE!:\n for making a new line
Alt Text
After that we will define a function and call it calc by using :def calc(x=x,y=2020)
after that we will return y-x
and call the function in print statement
Alt Text
thanks for reading , peace.

Top comments (1)

Collapse
 
doublepicebs profile image
Doublepicebs

Really nice!! Would be better if you used something like

import datetime
time = datetime.datetime.now()

and let the y to be time.year

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay