Learn Pain Less

HomeOur TeamContact
Python Tutorial for Beginners | Variables in Python
Pawneshwer Gupta
Pawneshwer Gupta
September 10, 2022
1 min
Python Tutorial for Beginners | Variables in Python

Variables are used to store data values, its just like a container.

We can change value of variable any time.


In python there is no command or keyword to create variables, variable is created automatically when we assign any value to it. And we also don’t need to provide type of variable, python will determine type of variable automatically.

a = 10
b = "Pawneshwer Gupta"

by this line of code, variable got created with name “a” and its value will be 10 of type integer and “b” with value Pawneshwer Gupta of type String.

In python we don’t need to define type and type can be changed anytime.

a = 6.5

now type of a is changed from integer to float value and it has new value 6.5. This is how we change type of variable in python.

x = str(3) # x will be '3'
y = int(3) # y will be 3
z = float(3) # z will be 3.0

How to get type of variable

to get type of variable python has a special function with name ”type()“.

x = 5
y = "John"

Double or Single quotes?

Both are used to create string variable, both have same meaning.

x = "John"
# is the same as
x = 'John'

Is Python Case Sensitive?

Yes Python is Case sensitive

a = 4
A = "Sally"
#A will not overwrite a

Subscribe to our newsletter!

We'll send you the best of our blog just once a month. We promise.




Pawneshwer Gupta

Pawneshwer Gupta

Software Developer

Pawneshwer Gupta works as a software engineer who is enthusiastic in creating efficient and innovative software solutions.



Social Media

Related Posts

Why Declare Variables as Local and Global
Why Declare Variables as Local and Global
February 08, 2015
1 min
Learn Pain Less  © 2024, All Rights Reserved.
Crafted with by Prolong Services

Quick Links

Advertise with usAbout UsContact Us

Social Media