Variables in Python

Python Variables

Variables are containers or memory locations used to store value. Variable values can be changed. Rules to declare variable in python.

1.     Variables can only start with alphabet or underscore

2.     Variables names can contain alphabet(a-z) and numbers(0-9)

3.     Variables name can not contain any space

4.     Keywords cannot be declared as variables

5.     Variables names can not contain any special character except underscore


print("Hello World!")
welcome_msg = "Hello World!"
print(welcome_msg)
msg = "Welcome!"
name = "Asad Raza"
print(msg+" "+name)
age = 20
print("John age is "+str(age))
price = 5.75
print("Price of Pize: "+str(price))
# Correct declared variables
name = "John"
weight = 60
name1 = "John"
last_name = "davy"
_last_name = "davy"
# Wrong declared variables
1name = "John"
weight* = 60
last-name = "davy"
Github:
https://github.com/asadraza825/python

Tags: Python, Python Programming,  Python Variables, Variables 
Next Post Previous Post
No Comment
Add Comment
comment url