Professional Documents
Culture Documents
Python Variables
Example 1: Assigning values to Variables in Python
Get Area using Python Variables
length = 1
width = 2.20
area = length * width
print ("The area is: " , area)
out put : The area is: 2.2
Example 2
x = 5
y = "SNU"
print(x)
print(y)
Example 3
x = "Python "
y = "is "
z = "awesome"
print(x + y + z)
Example 3 #Many Values to Multiple Variables
x, y, z = "Orange", "Banana", "Cherry"
print(x)
print(y)
print(z)
Input function
Example 4
name= input("Enter your name:")
print("Hello, " + name)
# printing
print("The sum of the two given numbers is {}
".format(addition))
Example 5
# printing it
print("The name of the user is {0} and his/her age is
{1}".format(name, age))
Example 6# This program says hello and asks for my name.
print('Hello, world!')
print('What is your name?') # ask for their name
myName = input() #The input() Function
print('It is good to meet you, ' + myName)
print('The length of your name is:')
print(len(myName))
print('What is your age?') # ask for their age
myAge = input()
print('You will be ' + str(int(myAge) + 1) + ' in a year.')