-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdatatypes.py
More file actions
76 lines (63 loc) · 1.19 KB
/
datatypes.py
File metadata and controls
76 lines (63 loc) · 1.19 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
74
75
76
a = 5
print("the type of a ",type(a))
b = 55.2
print("the type of b ",type(b))
c = 1 + 3j
print("the type of c",type(c))
print("c is a complex number",isinstance(1 + 6j,int))
# sequence type
# strings
str = "string with double quotes"
print(str)
str1 = '''A Multiline
String'''
print(str1)
str2 = "hello java "
str3 = "strings demo"
print(str2[6:]) # slicing
print(str2[4]) #4th character
print(str2 * 4) #repete
s = str2 + str3
print(s) # concatenation
#list
list1 = [5,5.5,"python","java",8, 8]
print(type(list1))
print(list1)
print(list1[:5])
print(list1 + list1)
print(list1 * 3)
list1[4] = "hi"
print(list1)
#tuple
tup = ("hi","welcome","to","python",3,3)
print(type(tup))
print(tup)
print(tup[3:])
print(tup + tup)
print(tup * 3)
#tup[3] = "hi"
#dictionary
d = {"first":1,2:'java',3:'php'}
for x,y in d.items():
print(x,y)
len(d)
print(type(d))
print(d[2])
print(d.keys())
print(d.values())
d[4] = 'perl'
print(d)
#boolean
print(type(True))
print(type(False))
#Set
set1 = set()
set2 = {'Java',2,3,'python',3}
print(set2)
print(type(set2))
set2.add(10)
print(set2)
set2.remove(3)
print(set2)
set2.add('python1')
print(set2)