-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExcHandle.py
More file actions
363 lines (258 loc) · 5.85 KB
/
Copy pathExcHandle.py
File metadata and controls
363 lines (258 loc) · 5.85 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
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
#try - except
#############################################################
# print("simple prog with out Exception Handlng")
#
# var = "today we are learning EH in python"
# res = var.index('java')
# print("the position of python = " , res)
#
# a = 20
# b = 40
# c = 60
# res = a + b + c
# print("addition res = " , res)
#
# print("complete")
#
## example with exception handling
# print("simple prog with out Exception Handlng")
#
# var = "today we are learning EH in python"
#
# try:
# res = var.index('java')
#
# except Exception as err:
# print("hey its ok lets ignore this error")
# res = "Not found"
# print("error reason = ", err)
#
#
# print("the position of java = " , res)
#
# a = 20
# b = 40
# c = 60
# res = a + b + c
# print("addition res = " , res)
#
# print("complete")
# File Example with out EH
#
# print("opening file ")
#
# try:
# fvar = open(r'sandy.txt' , 'r')
#
# except Exception as err:
# print("creating the file sandy.txt")
# fvar = open(r'sandy.txt', 'w')
#
# fvar.close()
#
# a = 400
# b = 90
# c = 1000
# res = a + b + c
# print("addition res = " , res)
#
# print("complete")
#####################################################################
#EH Example with File concept with data inside
#
# print("opening file ")
#
# try:
# fvar = opn(r'sandy.txt' , 'r')
#
# except Exception as err:
# print("creating the file sandy.txt")
# fvar = open(r'sandy.txt', 'w')
#
# fvar.close()
#
# a = 400
# b = 90
# c = 1000
# res = a + b + c
# print("addition res = " , res)
#
# print("complete")
# EH Example with File concept
# print("EH Example with File concept")
#
# try:
# fvar = open('sandy.txt','r')
#
# except FileNotFoundError as err:
# print("\n =============== Exception FNFE Block ========= \n")
# print("Hey boss its ok lets create file ")
# fvar = open('sandy.txt' , 'w')
# print("created file successfully")
# print("\n =============== Exception Block ========= \n")
#
# except NameError as err:
# print("\n =============== NAME ERR Block ========= \n")
# print("Hey boss lets correct the name ")
# fvar = open('sandy.txt' , 'r')
# print("\n =============== Exception Block ========= \n")
#
#
# fvar.close()
# print("complete")
############################ creating errors ##############################
# assert and raise
### assert statement example to create error
# assert condition , message
# simple example
# mobnum = str(input("enter the mobile number = "))
# res1 = len(mobnum)
# res2 = mobnum.isdigit()
# # assert condition , message
# assert res1==10 and res2 == True, "hey sarathi give correct number "
# print("Valid Mobile number")
#
# age = str(input("enter the age = "))
# assert int(age) >= 22 and int(age) <= 35 , "Invaid age"
# print("Valid age")
#
# print("complete")
#
# a = 20
# b = 40
# c = 60
# res = a + b + c
# print("addition res = " , res)
#
# print("complete")
# flag = 0
# while(True):
#
# mobnum = str(input("enter the mobile number = "))
#
# res1 = len(mobnum)
# res2 = mobnum.isdigit()
#
# # assert condition , "error message"
# try:
# assert res1==10 and res2 == True, "hey boss please give correct number "
# flag = 1
# except AssertionError as err:
# print("enter the mobile number again = ")
# mobnum = str(input("enter the mobile number = "))
#
# if(flag == 1):
# print("success i am goint to next step")
# break
# else:
# print("again enter te number boss")
#
# print("Valid Mobile number")
# using raise statement
#
# mobnum = str(input("enter the mobile number = "))
#
# res1 = len(mobnum)
# res2 = mobnum.isdigit()
#
# # raise category("error msg")
#
# if(res1 != 10 or res2 != True):
# raise FileNotFoundError("ashwini enter correct data ")
#
# else:
# print("Valid mobile number")
#
# print("complete")
#
#
# a = 20
# b = 40
# c = 60
# res = a + b + c
# print("addition res = " , res)
#
# print("complete")
### assert
#
# username = "santhosh"
# password = "Krishna@123"
# otp = 3428
#
# userin = str(input("enter the user name = "))
# assert userin == username , "invalid username"
# print("valid user name proceed next ")
#
# pwdin = str(input("enter the password = "))
# assert pwdin == password , "invalid password"
# print("valid password proceed next ")
#
# otpin = int(input("enter the otp = "))
# assert otpin == otp , "invalid otp"
# print("valid otp proceed next ")
#
#
# print("welcome to home page")
### raise
### if(cond):
#### raise Ecategory("msg")
username = "santhosh"
password = "Krishna@123"
otp = 3428
#
# userin = str(input("enter the user name = "))
# if(username != userin):
# raise KeyError("invalid username")
# print("valid user name proceed next ")
#
#
pwdin = str(input("enter the password = "))
# if(pwdin != password):
# raise ValueError("invalid password")
# print("valid password proceed next ")
#
#
otpin = int(input("enter the otp = "))
if(otpin != otp):
raise ValueError("invalid otp")
print("valid otp proceed next ")
#
#
#
# print("welcome to home page")
#
#
#
#
#
#
#
#
#
#assert userin == username and pwdin == password and otpin == otp , "Invalid cread try agaian"
# % >= 60
# back logs == 0
# end duration == 4
# interview == cleared
# perc = int(input("enter the perc = "))
# assert perc >= 60 , "Sorry you dont have enough perc"
# print("percentage is validated")
#
# backlogs = int(input("enter the backlogs = "))
# assert backlogs == 0 , "Sorry you have backlogs"
# print("backlogs is validated")
#
# duration = int(input("enter the eng duration = "))
# assert duration == 4 , "Sorry you dont have enough duration for the course"
# print("duration is validated")
#
# interview = str(input("did u clear the interview = "))
# assert interview == 'yes' , "Sorry dint clear interview"
# print("interview is validated")
#
# print("welcome to the company XYZ")
#
#
#
#
#