Python Variables and Types
Python Tutorial » Python Variables and Types
A Python variable is a reserved memory location to store values.
Python has no command for declaring a variable.
A variable is created the moment you first assign a value to it.
Example:
24
Werner
x = 24
y = "Werner"
print(x)
print(y)
Output: y = "Werner"
print(x)
print(y)
24
Werner
Variables do not need to be declared with any particular type, and can even change type after they have been set.
Example:
Werner
x = 12 # x is integer
x = "Werner" # x is now is type str
print(x)
Output: x = "Werner" # x is now is type str
print(x)
Werner
Get the Type - examples
You can get the data type of a variable with the type() function.
Example:
<class 'int'>
<class 'str'>
x = 24
y = "Werner"
print(type(x))
print(type(y))
Output:y = "Werner"
print(type(x))
print(type(y))
<class 'int'>
<class 'str'>
Python Single or Double Quotes?
String variables can be declared either by using single or double quotes:
Example:
MariAnn
MariAnn
z = "MariAnn"
print(z)
# is the same as
z = 'MariAnn'
print(z)
#double quotes are the same as single quotes:
Output:print(z)
# is the same as
z = 'MariAnn'
print(z)
#double quotes are the same as single quotes:
MariAnn
MariAnn
Python variables Case-Sensitive
Variable names are case-sensitive.
Example:
126
Saandy
a = 126
A = "Saandy"
#A will not overwrite a
Output:A = "Saandy"
#A will not overwrite a
126
Saandy
Variable type, Python3 variable, Set variable, Print variable in Python, How to input a variable, Casting, Operations
Python Variables and Types - python
Online Editor
This tool makes it easy to create, adjust, and experiment with custom colors for the web.
HTML Templates

Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.
CSS HTML Layout

Find here examples of creative and unique website layouts.
Free CSS HTML Menu

Find here examples of creative and unique website CSS HTML menu.