Variables are nothing but reserved memory locations to store values.
Python has no command for declaring a variable, unlike any programming language.
variable is created the moment you first assign a value to it.
For example-
x = 5
y = "John"
print(x)
print(y)
Variable Naming convention :
Variable name must starts with letter or underscore.
Variable name cannot start with numbers or any special characters.
A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
Variable names are case-sensitive (age, Age and AGE are three different variables)
Python uses the + character To combine both text and a variable:
Example-
x = "awesome"
print("Python is " + x)
We can also use the + character to add a variable to another variable:
x = "Python is "
y = "awesome"
z = x + y
print(z)
We cannot combine string and numbers, python will generate error, like following code does :
Example
x = 5
y = "John"
print(x + y)
Python allows you to assign a single value to several variables simultaneously. For example −
a = b = c = 1
a = b = c = 1, 2, "john"
Python has five standard data types −
Numbers
String
List
Tuple
Dictionary
All data types we will cover in comming blogs.