Python Variables

Video Lecture


  • Variables are named locations in memory that are used to hold a value that may be modified by the program.

  • A variable may take different values at different time during execution.

  • A variable name must be a valid identifier, means can be a group of both letters and digits, but they have to begin with a letter or an underscore.

Variable name should not be a keyword.

To understand variable, you can assume that variable is like a container that holds data.

Declaring Variable and Assigning Values

  • In Python, You don't need to specify the type of variable because Python is a type infer language.

  • You don't need to declare explicitly variable in Python. When you assign any value to the variable that variable is declared automatically.

  • Syntax :

    variable_name = value
    for e.g.
    name = "prowessapps"
    age  = 20
    salary = 20000
    tax_rate = 4.5
  • As you assign value to the variable, that variable becomes of that type.

  • To check the type of any variable you can use inbuilt function type ( ).

type ( ) Function :

>>> name = "prowessapps"
>>> type(name)
<class 'str'>  type of 'name' is 'string'

>>> age = 20
>>> type(age)
<class 'int'>  type of 'age' is 'int'

>>> rate = 4.5
>>> type(tax_rate)
<class 'float'>  type of 'rate' is 'float'

Python is dynamically typed language.

Meaning of dynamically typed :

Dynamically type means you can use same variable for different value in the same program.

As per your passed value to the variable, it will become of that type.

>>> a = 20
>>> type(a)
<class 'int'>  here 'a' is 'int'

>>> a = 2.3
>>> type(a)
<class 'float'>  now 'a' is 'float'

>>> a = "Hello"
>>> type(a)
<class 'str'>  now 'a' is 'string'

Multiple Assignment

Assigning single value to multiple variables :


Assigning multiple values to multiple variables:

x, y, z = 50, 2.3, "Hello"

Udemy APAC

Udemy APAC

Online Live Training

We provide online live training on a wide range of technologies for working professionals from Corporate. We also provide training for students from all streams such as Computer Science, Information Technology, Electrical and Mechanical Engineering, MCA, BCA.

Courses Offered :

  • C Programming
  • C++ Programming
  • Data Structure
  • Core Java
  • Python
  • Java Script
  • Advance Java (J2EE)
  • Hibernate
  • Spring
  • Spring Boot
  • Data Science
  • JUnit
  • TestNg
  • Git
  • Maven
  • Automation Testing - Selenium
  • API Testing

NOTE: The training is delivered in full during weekends and during the evenings during the week, depending on the schedule.

If you have any requirements, please send them to or

Projects For Students

Students can contact us for their projects on different technologies Core Java, Advance Java, Android etc.

Students can mail requirement at

(8AM to 10PM):

+91-8527238801 , +91-9451396824

© 2017,, All rights reserved