-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path02_Datatypes.py
More file actions
51 lines (38 loc) · 1003 Bytes
/
02_Datatypes.py
File metadata and controls
51 lines (38 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Numeric - int, float, complex
# Sequence Type - string, list, tuple
# Mapping Type - dict
# Boolean - bool
# Set Type - set, frozenset
# Binary Types - bytes, bytearray, memoryview """
# 1. Numeric Datatypes
a = 10
b = 10.5
c = 1 + 2j
print(type(a))
print(type(b))
print(type(c))
# 2. Sequence Datatype
# String - immutable
str = 'Welcome to the Geeks World'
print(type(str))
str1 = """This is a multi-line string.
It can span multiple lines."""
print(str1)
# list - mutable
lst = ["Geeks", "For", "Geeks", 4, 5]
print(type(lst))
# tuple - immutable
tup = ("Geeks", "For", "Geeks", 4, 5)
print(type(tup))
# 3. Mapping Datatype
# Dictionary - mutable, unordered collection of key-value pairs
dict_var = {"name": "Geeks", "age": 5}
print(type(dict_var))
# 4.Boolean Datatype
bool_var = True
print(type(bool_var))
print(int(bool_var)) # Converts True to 1 and False to 0
# 5. Set Datatype
# Set - mutable, unordered collection of unique items
set_var = {1, 2, 3, 4, 5}
print(type(set_var))