-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day1.py
350 lines (289 loc) · 8.66 KB
/
Day1.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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
#beginner programs
#program to swap two numbers in one line
# a=4
# b=7
# a,b=b,a
# print(a,b)
#program to take two inputs from user and add them
# a=int(input('enter one number'))
# b=int(input('enter second number'))
# res=a+b
# print('Result is: ', res)
#program performing operations according to user
# a = int(input('enter one number'))
# b = int(input('enter second number'))
#
# switcher = {
# 'A': a + b,
# 'S': a - b,
# 'D': a / b,
# 'M': a * b,
# 'R': a % b,
# }
#
# choice = input('Press A for addition, S for subtraction, D for division, M for multilicaton. R for remainder')
#
# print('Result is :', switcher.get(choice, 'Invalid choice'))
#DAY 2
#WAP for eligibility of license
# age=int(input('Enter age'))
# if(age<16):
# print('Not eligible')
# elif(age>=16 or age<18):
# print('Eligible for learner license')
# else:
# print('Eligible')
#WAP for quad eqn
# a=int(input("Enter a "))
# b=int(input("Enter b "))
# res=(2*a*a)+(3*b)
# print(res)
#WAP to check for leap year
# def is_leap(year):
# leap = False
#
# if(year%4==0):
# if(year%100==0):
# if(year%400==0):
# leap=True
# else:
# leap=True
#
# return leap
#
# year = int(input("Enter year to check for leap year"))
# print(is_leap(year))
#WAP to find prime numbers between 1-100
# for i in range(2,101):
# c=0
# for j in range(1,i+1):
# if(i%j==0):
# c=c+1
# if(c==2):
# print(i, end=' ')
#WAP to print table of a number
# num=int(input("Which number table do u want?"))
# for i in range(1,11):
# print(num,'*',i,'=',i*num)
#WAP to print calendar
# import calendar
# print(calendar.month(2019,4))
#WAP to perform user defined func
# ch=input("Enter your choice: A to add, S to subtract, D to divide, M to multiply")
#
# def add(a,b):
# return a+b
# def sub(a,b):
# return a-b
#
# def div(a,b):
# return a/b
#
# def mul(a,b):
# return a*b
#
# a=int(input("Enter num1"))
# b=int(input("Enter num2"))
# if(ch=='a' or ch=='A'):
# i=add(a,b)
# print(i)
# if(ch=='s' or ch=='S'):
# if(b>a):
# j=sub(a=b,b=a)
# else:
# j=sub(a,b)
# print(j)
# if(ch=='d' or ch=='D'):
# k=div(a,b)
# print(k)
# if(ch=='m' or ch=='M'):
# l=mul(a,b)
# print(l)
#WAP to find factorial
# a=int(input("Enter number to find factorial"))
#
# def fact(a):
# if(a==1):
# return 1
# else:
# return a*fact(a-1)
#
# f=fact(a)
# print("***********Factorial is ************", f)
# Take age program and continue the program till the user has not entered 'n' character. Before exiting the program, print all the age parameters tested by the user.
# def check(age):
# if(age<16):
# print('Not eligible')
# elif(age>=16 or age<18):
# print('Eligible for learner license')
# else:
# print('Eligible')
# n=1
# agelist=[]
# while(n!=10):
# age =int(input('Enter age'))
# agelist.append(age)
# check(age)
# n=n+1
# print(agelist)
#Correct solution:
# tested_ages=[]
# while(True):
# age=input("Enter your age")
#
# if(age=='n'):
# break
# else:
# age=int(age)
# if(age>=18):
# print("Eligible")
# else:
# print("Not eligible")
#
# tested_ages.append(age)
#
# print("Age parameters tested: ", tested_ages)
# 2. Take age program, print a dictionary that should display the parameter entered by the user and then display the corresponding value for that age parameter.
# (Print all the key and values of dictionary separately.)
# eligible_age=[]
# noteligible_age=[]
# tested_dict={}
#
# while(True):
# age = input("Enter your age")
#
# if(age=='n'):
# break
#
# else:
# age=int(age)
# if(age>=18):
# eligible_age.append(age)
# else:
# noteligible_age.append(age)
#
# tested_dict['Eligible']=eligible_age
# tested_dict['Not eligible']=noteligible_age
# print("Age parameters tested are: ", tested_dict)
# 3. Take three lines input from the user, separated by "." Using some inbuilt functions and
# add those lines in a list and then print those lines.
#print(input("enter any string including three lines").split('.'))
# 4. Take input from user a particular paragraph and print the frequency of words in that paragraph.
# stlist=input("Enter a paragraph").split(' ')
# nlist=[]
# for i in stlist:
# if(i not in nlist):
# nlist.append(i)
# for j in range(0,len(nlist)):
# print('Frequency of ',nlist[j],'is', stlist.count(nlist[j]))
#5. Write a Python program to print out a set containing all the colors from color_list_1 which are not present in color_list_2.
# clist1=[input("Enter colours for list one") for i in range(0,5)]
# clist2=[input("Enter colours for list two") for j in range(0,5)]
# nlist=[]
# for i in range(0,len(clist1)):
# if(i not in clist2):
# nlist.append(clist1[i])
# print(nlist)
# if we would have written set(nlist)
# then set removes the repeated elements, that is, it removes duplicacy.
# 6. Write a program to find maximum and minimum numbers from a set of inputs given by the user. [Do not use built-in functions.]
# list1 = [ int(input("Enter num")) for i in range(6)]
# min=list1[0]
# max = list1[0]
# for i in list1:
# if ( i > max):
# max=i
# if ( i < min):
# min=i
#
# print("Maximum value is : ", max)
# print("Minimum value is : ", min)
# 7. Using list comprehension, create a list of numbers in between a specific range.
# a=int(input("Enter strt of range"))
# b=int(input("Enter end of range"))
# print([i for i in range(a,b+1)])
# 8. Add more than 2 or more elements to the list in one line.
# listadd=[input("Enter element ") for i in range(0,5)]
# print(listadd)
# 9. Write a function to take in a list of girls and boys and find every possible girl-boy dance combinations for a dance partnership
# g=int(input("Enter number of girls"))
# girls=[input("Enter girl ") for i in range(0,g)]
# b=int(input("Enter number of boys"))
# boys=[input("Enter boy ") for j in range(0,b)]
#
# for i in girls:
# for j in boys:
# print(i,'-',j)
import tkinter as tk
import sqlite3
# con =sqlite3.connect('guidb.db')
#
# TABLE_NAME = "student_tablegui"
# STUDENT_ID = "student_id"
# STUDENT_NAME = "student_name"
# STUDENT_COLLEGE = "student_college"
# STUDENT_ADDRESS = "student_address"
# STUDENT_PHONE = "student_phone"
#
# window=tk.Tk()
# window.title("GUI Database")
#
#
# name_label = tk.Label(window, text="Enter name")
# name_label.pack()
# field1 = tk.Entry(window)
# field1.pack()
#
# college_label = tk.Label(window, text="Enter college")
# college_label.pack()
# field2 = tk.Entry(window)
# field2.pack()
#
# address_label = tk.Label(window, text="Enter address")
# address_label.pack()
# field3 = tk.Entry(window)
# field3.pack()
#
# phone_label = tk.Label(window, text="Enter phone")
# phone_label.pack()
# field4 = tk.Entry(window)
# field4.pack()
#
#
# def entries():
# con.execute(" CREATE TABLE IF NOT EXISTS " + TABLE_NAME +
# "( " + STUDENT_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + STUDENT_NAME + " TEXT, " +
# STUDENT_COLLEGE + " TEXT, " +
# STUDENT_ADDRESS + " TEXT, " + STUDENT_PHONE +
# " INTEGER);")
#
# print("table created successfully!")
# name = field1.get()
# college = field2.get()
# address = field3.get()
# phone = field4.get()
#
# con.execute("INSERT INTO " + TABLE_NAME + " ( " + STUDENT_NAME + ", " +
# STUDENT_COLLEGE + ", " + STUDENT_ADDRESS + ", " + STUDENT_PHONE + ") "
# "VALUES ( '"+name+"', '"+college+"', '"+address+"', "+phone+"); ")
# con.commit()
#
# def display():
# cursor = con.execute("SELECT * FROM " + TABLE_NAME + " ;")
# for row in cursor:
# print("Student id is: ", row[0])
# print("Student name is: ", row[1])
# print("Student college is: ", row[2])
# print("Student address is : ", row[3])
# print("Student phone numbr is : ", row[4])
#
# con.close()
#
#
# button = tk.Button(window, text="Submit", command=lambda: entries())
# button.pack()
#
# display_button = tk.Button(window, text="Display", command=lambda: display())
# display_button.pack()
#
# window.mainloop()