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 …


This content originally appeared on DEV Community and was authored by aryan015

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

Thank you


This content originally appeared on DEV Community and was authored by aryan015


Print Share Comment Cite Upload Translate Updates
APA

aryan015 | Sciencx (2024-07-19T17:28:24+00:00) 5. Writing our first program in python with home🧡work. Retrieved from https://www.scien.cx/2024/07/19/5-writing-our-first-program-in-python-with-home%f0%9f%a7%a1work/

MLA
" » 5. Writing our first program in python with home🧡work." aryan015 | Sciencx - Friday July 19, 2024, https://www.scien.cx/2024/07/19/5-writing-our-first-program-in-python-with-home%f0%9f%a7%a1work/
HARVARD
aryan015 | Sciencx Friday July 19, 2024 » 5. Writing our first program in python with home🧡work., viewed ,<https://www.scien.cx/2024/07/19/5-writing-our-first-program-in-python-with-home%f0%9f%a7%a1work/>
VANCOUVER
aryan015 | Sciencx - » 5. Writing our first program in python with home🧡work. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/07/19/5-writing-our-first-program-in-python-with-home%f0%9f%a7%a1work/
CHICAGO
" » 5. Writing our first program in python with home🧡work." aryan015 | Sciencx - Accessed . https://www.scien.cx/2024/07/19/5-writing-our-first-program-in-python-with-home%f0%9f%a7%a1work/
IEEE
" » 5. Writing our first program in python with home🧡work." aryan015 | Sciencx [Online]. Available: https://www.scien.cx/2024/07/19/5-writing-our-first-program-in-python-with-home%f0%9f%a7%a1work/. [Accessed: ]
rf:citation
» 5. Writing our first program in python with home🧡work | aryan015 | Sciencx | https://www.scien.cx/2024/07/19/5-writing-our-first-program-in-python-with-home%f0%9f%a7%a1work/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.