-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay5.py
More file actions
73 lines (53 loc) · 1.72 KB
/
Day5.py
File metadata and controls
73 lines (53 loc) · 1.72 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Title : Datatypes, A basic overview
# What is variable?
# A variable is like a container that holds the data.
a = 1 # Integer datatype
print(a)
b = "Light" # String datatype
print(b)
c = True # Boolean datatype
print(c)
d = None # None-type datatype
print(d)
# print(a + b)
# This will throw an error since one variable is int and other string
# type() function tells us about the variable datatype
print("The type of a is ", type(a))
print("The type of b is ", type(b))
print("The type of c is ", type(c))
print("The type of d is ", type(d))
# Builtin datatypes in python
# 1) Numeric - INT, Float, Complex
# Int Datatype
N1 = 5
print(N1, ", The type: ", type(N1))
# Float Datatype
N2 = 6.9
print(N2, ", The type: ", type(N2))
# Complex Datatype
N3 = complex(6, 9)
print(N3, ", The type: ", type(N3))
# Text Datatype - String
S1 = "Light"
print(S1, ",The type: ", type(S1))
S2 = "Light is a good boi"
print(S2, ",The type: ", type(S2))
# Boolean Datatype
B1 = True
B2 = False
print(B1, "&", B2, ", The types: ", type(B1), "&", type(B2))
# Sequenced Datatype - List and Tuple
# List datatype
# simply list is collection of different datatype and are mutable or changeable
list1 = [8, 2, 4, [-4, 5], ["Light", "Dark"]]
print(list1, ", The type: ", type(list1))
# Tuple datatype
# Same a list but these are immutable
tuple1 = (("Light", "Dark"), ("Code", "Coding"))
print(tuple1, ", The Type: ", type(tuple1))
# Mapped Datatype - dict
# dict - a dictionary is an unordered collection of data containing a key:value pair.
# The key:value pairs are enclosed within curly{} brackets
dict1 = {"name": "Light", "age": 20, "canVote": True}
print(dict1, ", The type: ", type(dict1))
# Interesting fact : Everything in python is an 'Object'