Skip to content
Understanding variables in Python
Profile icon
PavanBaddi

Python is a dynamically typed programming language which means there is no need to declare the data type of variable.

Example

x=12 y="hello world" z=15.45 print(x) print(y) print(z) #PTHON OUTPUT 12 hello world 15.45

To check variable belongs to which data type use type()  built-in method in python.

Example

x = 15 #<class 'int'> interger y = "Hello Python" #<class 'str'> string z = 21.20 #<class 'float'> float a = True #<class 'bool'> boolean #print all Variables print(x, y, z, a) #print datatype of Variables print(type(x), type(y), type(z), type(a)) #python output <class 'int'> <class 'str'> <class 'float'> <class 'bool'>

Combine Variables

In python, operators are used to combining, do mathematical calculation or logical conditioning.

Example

a = 10 b = 5 c = 10+5 print(c) #python output 15

The article was taken from the code learners website

You are viewing a single comment. View All
Profile icon
glamourgirl

Awesome!
:D!