Datatypes in Python
Data types specify the different sizes and values that can be stored in the variable. For example, Python stores numbers, strings, and a list of values using different data types.
There are mainly Five types of basic/primitive data types available in Python
Numeric: int, float, and complex
Bool:true,false
Sequence: String, list, and tuple
Set
Dictionary (dict)
int datatype :
# single variable declaration with value assigning
Ex:
x=50
print(x)
# multi variable declaration with value assigning
Ex:
x,y=90,60
print(x)
print(y)
# int variable declaration input from user using input function
Ex:
x=int(input("enter x value"))
print(x)
print(type(x)) # display the datatype of x variable value
#enter input value
50
output:
50
<class : int>
# Variable declaration input from user without using input function
roll_no=input("enter rollnumber")
print(roll_no)
print(type(roll_no))
input : enter roll_no
101
output:
101
<class : str> #python default datatype string
Comments
Post a Comment