-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpro4.py
More file actions
116 lines (93 loc) · 2.55 KB
/
Copy pathpro4.py
File metadata and controls
116 lines (93 loc) · 2.55 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# student = {
# "name" : "john doe",
# "age" :20,
# "course":"AI engineering",
# "marks" : 85,
# "adress" :"123 main city"
# }
# print(student)
# dic ={
# "name" : "amina",
# "class" : "pysics",
# "marks" :[0,60,87,90],
# "subject" :
# {
# "math" : 90,
# "english" : 80,
# "science" : 85
# }
# }
# print(dic["class"])
# print(dic["subject"]["math"])
# print(dic["subject"]["english"])
# print(dic["subject"]["science"])
# dic["subject"]["math"] = 95
# dic["name"] = "amina khan"
# print(dic)
# dictionary methods
# methods = {
# "id" : 1,
# "class" : "python",
# "cell" : 1234567890,
# "roll" :10,
# "city" : "lahore"
# }
# print(methods.keys())
# print(methods.values())
# print(list(methods.items( )))
# print(methods.get("class"))
# student = {
# "name": "John Doe",
# }
# new_dict = {"city": "New York",
# "age": 20
# }
# # concate
# student.update(new_dict)
# print(student)
#sets in python
# collection = {1, 2, 3, 2, 5, "hello", (1, 2, 3)}
# print(collection) # ignore repeted values
# print(type(collection))
# set ={10,4.5, 6, 7, "computer", "campus" , ('h', 1, 4.5, 7)}
# print(set)
# print(type(set))
# set.add("python")
# print(set)
# set.remove(10)
# print(set)
# set.clear()
# print(set)
# set.pop()
# print(set)
# set1 = {1,2,3,4,5,}
# set2 ={"china" , "india", 1, 3, 5, 2, 5}
# print(set1.union(set2))
# print(set1.intersection(set2))
#practice questions
#Store following word meanings in apython dictionary
# dictionary ={
# "cat" : " a small animal",
# "table" : [" a piece of furniture", "used for eating and working"]
# }
# print(dictionary)
#Youare given alist of subjects for students. Assume one classroom is required for 1 subject. Find out how many classrooms are required for the following subjects.
# subjects = {"math", "english", "english", "python", "urdu"}
# print(subjects)
# print(len(subjects))
# WAPto enter marks of 3subjects from the user andstore them in adictionary. Start with an empty dictionary and add key value pairs to it. Finally print the dictionary.
# marks ={}
# m = int(input("enter marks of math subject:"))
# marks.update({"math" :m})
# m = int(input("enter marks of english subject:"))
# marks.update({"english" :m})
# m= int(input("enter marks of physics subjects:"))
# marks.update({"physics" : m})
#Figure out awayto store 9 &9.0as separate values in the set. (You can take help of built-in data types)
values ={ 9, "9.0"}
print(values)
value1 = {
("float", 9.0),
("int" , 9)
}
print(value1)