-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample.py
More file actions
51 lines (38 loc) · 1.01 KB
/
Copy pathExample.py
File metadata and controls
51 lines (38 loc) · 1.01 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
#Set x as a integer
x = 10
#set y as a float
y = 3.35
#set strg as a string
strg = "Hello"
#set sw as a boolean
sw = True
#print the values of the variables
print(x)
print(y)
print(strg)
print(sw)
#printing the type of variable is shown below
print("x is of type ", type(x))
print("y is of type ", type(y))
print("strg is of type ", type(strg))
print("sw is of type ", type(sw))
#arrays are declared as
a = [1,2,3,4,5,6,7,8]
#elements in arrays can be printed as
print("a[2] is = ", a[2])
print(type(a))
print("a[0:3] = ", a[0:3])
#a tuple can be used to store a list with different values
t = (14,'Hello',1+3j)
print('the tuple is shown', t)
print('the first two values are = ', t[0:2])
print('the value at t[2] = ', t[2])
#a set can be declared as shown
s = {1,2,3,4,5}
print(s)
# a dictionary can be declared as shown
d = {1 : 'value' , 'key' : 2}
print('the dictionary is = ', d)
print('the type of dictionary is shown = ', type(d))
print('the value at d[1] is = ', d[1])
print("the value at d['key'] = ", d['key'])