DEV Community

Dr. Azad Rasul
Dr. Azad Rasul

Posted on

6- Data types in Python Programming

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'
Enter fullscreen mode Exit fullscreen mode

2- Float:

x = 22.5
type(x) # class ‘float’
Enter fullscreen mode Exit fullscreen mode

3- Complex:

z = 5 + 10j
type(z) # class 'complex'
Enter fullscreen mode Exit fullscreen mode

4- Boolean: bool is true or false

isFactor = False
type(isFactor) # class 'bool'
Enter fullscreen mode Exit fullscreen mode

5- Strings: str

name = "Anas"
type(name) class 'str'
Enter fullscreen mode Exit fullscreen mode

6- Nothing: NoneType

precipitation = None
type(precipitation) # class 'NoneType'
Enter fullscreen mode Exit fullscreen mode

Container data types in Python:

1- tuple:

color = ("red", "blue", "green")
type(color) # class 'tuple'
Enter fullscreen mode Exit fullscreen mode

2- list:

Color = [red, blue, green]
type(Color) # class 'list'
Enter fullscreen mode Exit fullscreen mode

3-set:

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

4- dict: dictionary

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

5- range:

y = range(100)
type(y) # class 'range'
Enter fullscreen mode Exit fullscreen mode

If you like the content, please SUBSCRIBE to my channel for the future content.

To get full video tutorial and certificate, please, enroll in the course through this link: https://www.udemy.com/course/python-for-researchers/?referralCode=886CCF5C552567F1C4E7

Top comments (0)