Azad Rasul
SmartRS

SmartRS

6- Types of data in Python

Azad Rasul's photo
Azad Rasul

Published on Jun 26, 2021

1 min read

Subscribe to my newsletter and never miss my upcoming articles

Variables in Python

  • Variables dynamically typed in Python.
  • Python is case sensitive; it differentiates between capital (Erbil) and small letters (erbil).
  • The first letter of variables cannot start with digits (i.e. 3Erbil).

Main data types in Python

1- Integers: int

Age = 55 
Type(Age) # class 'int'

2- Float:

x = 22.5
type(x) # classfloat

3- Complex:

z = 5 + 10j
type(z) # class 'complex'

4- Boolean: bool is true or false

isFactor = False
type(isFactor) # class 'bool'

5- Strings: str

name = "Anas"
type(name) class 'str'

6- Nothing: NoneType

precipitation = None
type(precipitation) # class 'NoneType'

Container data types in Python:

1- tuple:

color = ("red", "blue", "green")
type(color) # class 'tuple'

2- list:

Color = [“red”, “blue”, “green”]
type(color) # class 'list'

3-set:

food = set(["rice" , "egg", "yogurt"])
type(food) # class 'set'

4- dict: dictionary

age = {'Anas': '8', 'Aviar': '6', 'Muhammad': '5'}
type(age) # class 'dict'

5- range:

y = range(100)
type(y) # class 'range'
 
Share this
Proudly part of