repl.it
@MuntahaIslam/

Variables & Type Conversion

Python

Examples of variable usage in Python.

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
name = input("What's your name buddy? ")
print("Hello " + name + "! Welcome to this Repl.")

# Well, like all other languages, Python has variables.
# But, every input is been taken as a String.
# For instance ...

birthYear = input("Please enter your birth-year: ")
print(type(birthYear))

# Now to use this string as an int, one need to define type.
currentYear = input("Please enter current year: ")

print("So, now you're " + str(int(currentYear) - int(birthYear)))
print(type(currentYear))
?