-
Notifications
You must be signed in to change notification settings - Fork 0
/
chandra.py
201 lines (144 loc) · 3.86 KB
/
chandra.py
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# This is extend dict:
# marks = {
# "year1": [80, 90, 85],
# "year2": [75, 95, 82],
# "year3": [72, 88, 94],
# }
# marks["year4"] = [89, 92, 95, 87]
# print(marks)
# this is insert dict:
# years = {
# "1st year": ["45,89,67,89"],
# "2nd year":["56,67,89,78"],
# "3rd year":["68,89,90,96"],
# }
# years.update({"4th year": ["89, 92, 95, 87"]})
# print(years)
# employ = {
# "FirstName": "jaya",
# "LastName": "devarinti",
# "employeeI-D": 6281958978,
# "Designation": "DevOps Engineer",
# "LanguageExpertise": ["AWS","Python"],
# "bike": {
# "Make&Model": "pulser yamaha",
# "MakeYear": 2023,
# "Color": "black",
# }
# }
# {
# "FirstName": "venkat",
# "LastName": "reddy",
# "employeeID": 7995910832,
# "Designation": "python developer",
# "LanguageExpertise": ["python", "AWS"],
# "Car": {
# "Make&Model": "Hyundai Verna",
# "MakeYear": 2023,
# "Color": "white",
# }
# }
# print(employ)
# a={
# "FirstName": "jaya",
# "LastName": "chandra",
# "employeeID": 7995910832,
# "Designation": "python developer",
# }
# e=len(a)
# for i in range(e):
# var=input("Enter a key :")
# if var in a:
# print("Key exist in JSON data")
# print(a[var])
# else:
# print("Key doesn't exist in Json data")
# dict1={
# "name":"jaya",
# "age":23,
# "gender":"male",
# "number":"6281958978",
# "adress":"rayachoti",
# }
# fun=len(dict1)
# for i in range(fun):
# var=input("enter any key:")
# if var in dict1:
# print("key is existing ")
# print(dict1[var])
# else:
# print("key is not existing ")
# user_list = []
# for i in range(10):
# user_input = input(f"Enter item {i + 1}: ")
# user_list.append(user_input)
# print("The list is: ", user_list)
# import random
# my_list = [1, 2, 3, 4, 5]
# random_item = random.choice(my_list)
# print("Random item: ", random_item)
# index = my_list.index(random_item)
# print(f"Index of the random item: {index}")
# 09/02/2023
# ---------
# spam = ['cats', 'dogs', 'moose']
# bacon = ['dogs', 'moose', 'cats']
# spam == bacon
# print(spam==bacon)
# eggs ={'name': 'Zophie', 'species': 'cat', 'age': '8'}
# ham = {'species': 'cat', 'age': '8', 'name': 'Zophie'}
# eggs == ham
# print(eggs==ham)
# spam = {'name': 'Zophie', 'age': 7}
# spam['age']
# print(spam['age'])
# spam = {}
# spam['first key'] = 'value'
# spam['second key'] = 'value'
# spam['third key'] = 'value'
# list(spam)
# print(list(spam))
# dictinaries are supported three types[keys(),values(),items()]
# spam = {'color': 'red', 'age': 42}
# for i in spam.keys():
# print(i)
# spam = {'color': 'red', 'age': 42}
# for i in spam.values():
# print(i)
# spam = {'color': 'red', 'age': 42}
# for i in spam.items():
# print(i)
# spam = {'color': 'red', 'age': 42}
# for k, v in spam.items():
# print('Key: ' + k + ' Value: ' + str(v))
# birthdays = {'Alice': 'Apr 1', 'Bob': 'Dec 12', 'Carol': 'Mar 4'}
# while True:
# print('Enter a name: (blank to quit)')
# name = input()
# if name == '':
# break
# if name in birthdays:
# print(birthdays[name] + ' is the birthday of ' + name)
# else:
# print('I do not have birthday information for ' + name)
# print('What is their birthday?')
# bday = input()
# birthdays[name] = bday
# print('Birthday database updated.')
# get() method:
# picnicItems = {'apples': 5, 'cups': 2}
# # print('I am bringing ' + str(picnicItems.get('cups',0)) + ' cups.')
# print('i am bringing' + str(picnicItems.get('apples',0)) +' apples ')
# setdefault()method:
# spam = {'name': 'jaya', 'age': 5}
# spam.setdefault('color', 'black')
# print(spam)
# count() in dictionary
# import pprint
# message = 'It was a bright cold day in April, and the clocks were striking thirteen.'
# count = {}
# for character in message:
# count.setdefault(character, 0)
# count[character] = count[character] + 1
# pprint.pprint(count)
# 10/02/2023