Variable and Datatype in Python

What is Variable?

  • Named memory location used for storing the value in the entered by the user.
  • Stores only one value at a time

What is Datatype?
Datatype determines type of value to be stored.

Description Java Python
Variable Declaration Mandatory Not Mandatory
Datatype int,float,double,char,boolean,long,String str,int,float
Example String sname=”Sanjay” sname=”Sanjay”

Example: Python Variable Declaration
# Variable in python

print(“Employee details:”)
print(“Employee No. : “, empno)
print(“Employee Name=”, empName)
print(“Salary=”, salary)

Python supports Dynamic Typing means based on the value stored in the Variable datatype will be automatically assigned to the variable.
type() function is used to Find the variable’s datatype at Run time.
Example: print(“empno – datatype :”, type(empno))

Next Part : Python Calculation

Win Corporate Training
View My Profile