Python-Buildin-Types
Wed 12 November 2025
# created : 20250113
# https://www.scientecheasy.com/2022/09/data-types-in-python.html/
# Dynamic data
# which means we dont want to specify a data type when assigning to a variable
# the change in the value leads to a change in data type
my_var = "Hi Friends!" # holding string.
my_var = 25 # same variable holding numeric value.
my_var = True #holding a boolean
# print(my_var)
num1 = 10 #--> string value
percentage = 80.50 # --> floating value
print(num1)
print(percentage)
10
80.5
# Int Data type
num1 = 10
num2 = 20
num3 = 30
print(num1)
print(num2)
print(num3)
10
20
30
# Floating data type
num1 = 10.555
num2 = 20.99
result = num1 + num2
print(result)
31.544999999999998
# Complex Data type
num1 = 2 + 5j
num2 = 3.5 + 7.5j
result = num1 + num2
print(result)
(5.5+12.5j)
# determine the type of variable
num1 = 50
num2 = 20.50
num3 = 3.5 + 7.5j
print(type(num1))
print(type(num2))
print(type(num3))
<class 'int'>
<class 'float'>
<class 'complex'>
num1 = 20
num2 = 50
del num1
print(num1) # --> iwll raise error because num1 deleted
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[3], line 2
1 del num1
----> 2 print(num1)
NameError: name 'num1' is not defined
# Boolean Data type
a = (10 >= 4)
b = (25 == 5 * 5)
c = (18 != 2 * 9)
print(a, b, c)
True True False
# None Data type
a = None
print(a)
print(type(a))
None
<class 'NoneType'>
# String Data type
str1 = "Hello Jerin"
str2 = 'How are you ?'
print(str1)
print(str2)
print(type(str1))
Hello Jerin
How are you ?
<class 'str'>
# List Data type
list = [10, 20.50, "Python", True]
print(list)
print(type(list))
[10, 20.5, 'Python', True]
<class 'list'>
num_list = [10, 20, 30, 40]
print(num_list)
[10, 20, 30, 40]
num_list[2] = 50
print(num_list)
[10, 20, 50, 40]
# Tuple Data type
#
t = (10, 20, "Python", 2 + 10j)
print(t)
print(type(t))
(10, 20, 'Python', (2+10j))
<class 'tuple'>
# Set Data type
s = {1, 2, 'Hello', 4 + 50j}
print(s)
print(type(s))
{1, 'Hello', 2, (4+50j)}
<class 'set'>
# Dictionary Data type
dict = {1 : 'Orange',
2 : 'Apple',
3 : 'Banana'}
print(dict)
print(type(dict))
{1: 'Orange', 2: 'Apple', 3: 'Banana'}
<class 'dict'>
Score: 40
Category: python-basics