-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexception.py
More file actions
249 lines (203 loc) · 6.25 KB
/
exception.py
File metadata and controls
249 lines (203 loc) · 6.25 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
"""exeception """
# try:
# num1 = input("enter first value: ")
# num2 = input("enter second value: ")
# print(num1/num2)
# except Exception:
# print("beta lg gye tumhare......")
# else:
# print("no error occur")
# try:
# num1 = int(input("enter first value: "))
# num2 = int(input("enter second value: "))
# print(num1/num2)
# except ZeroDivisionError:
# print("beta zero se divide mt kro")
# num1 = int(input("enter first value: "))
# num2 = int(input("enter second value: "))
# print(num1/num2)
# except Exception as e:
# print("error tumhare......")
# else:
# print("no error occur")
# while True:
# try:
# num1 = int(input("enter first value: "))
# num2 = int(input("enter second value: "))
# print(num1/num2)
# except ZeroDivisionError:
# print("beta zero se divide mt kro")
# except Exception as e:
# print("error tumhare......" , e)
# else:
# break
# while True:
# try:
# num1 = int(input("enter first value: "))
# num2 = int(input("enter second value: "))
# print(num1/num2)
# except ZeroDivisionError:
# print("beta zero se divide mt kro")
# except ValueError:
# print("beta value se divide mt kro")
# except Exception as e:
# print("error tumhare......" , e)
# else:
# break
# count = 1
# while count >1:
# try:
# num1 = int(input("enter first value: "))
# num2 = int(input("enter second value: "))
# print(num1/num2)
# except ZeroDivisionError:
# count +1
# except ValueError:
# count +1
# except Exception as e:
# count +1
# else:
# break
# try:
# a = "shekhar"
# print(a+"9")
# except Exception as e:
# print(e)
# try:
# age = int(input("enter the age :"))
# if age< 18:
# print("age error occured")
# raise
# else:
# print("you are eligible for voting")
# except Exception as e:
# print("error is -->>>",e)
# try:
# age = int(input("enter the age :"))
# if age< 18:
# print("age error occured")
# raise Exception
# else:
# print("you are eligible for voting")
# except Exception as e:
# e = "age error"
# print("error is -->>>",e)
# try:
# age = int(input("enter the age :"))
# if age< 18:
# print("age error occured")
# raise ValueError ("error")
# else:
# print("you are eligible for voting")
# except Exception as e:
# print("error is -->>>",e)
# def atm_simulation():
# try:
# balance =10000
# while True:
# print("""
# welcome to my ATM
# press 1 for exit
# press 2 for deposit
# press 3 for withdrow """)
# decision=int(input("enter 1/2/3 : "))
# if decision==1:
# print(" Thanks For Using my ATM")
# break
# elif decision==2:
# deposit_amount=int(input("enter the amount to deposit : "))
# balance+=deposit_amount
# print("your balanceis ",balance)
# elif decision==3:
# w_amount=int(input("enter the amount to withdrow : "))
# if balance>=w_amount:
# balance-=w_amount
# else:
# raise ValueError("transaction fail due to insufficent balance")
# print("remaining balance",balance)
# else:
# print("invalid input")
# except Exception as e:
# print("error",e)
# atm_simulation()
"""file handeling"""
# # file = open("file_name.extension(txt)','mode")
# '''
# r = read
# w = write
# a = append
# + - read and write
# '''
# file = open("regex.txt","r")
# con = file.read()
# print(con)
# file.close()
# file = open ("regex.txt",'a')
# file.write("\n this is append new ")
# file.close()
# file = open ("regex2.txt", 'a')
# file.write("i am inside regex2 file")
# file.close()
# with open("regex.txt",'r') as file:
# file.write("line 1")
# file.write("\nline2")
# with open("regex.txt","r") as source,open("regex2.txt","a") as destination:
# for line in source:
# destination.write('\n'+line)
# with open("regex.txt","r") as source,open("regex2.txt","a") as destination:
# context1 = source.read()
# context2 = destination.read()
# print(context1)
# print(context2)
# with open("regex.txt","r") as file:
# for line in file :
# print (line)
# with open("regex.txt","r") as file:
# count = 0
# for line in file :
# count+=len(line.split())
# print(count)
# with open ("regex.txt" , 'r') as file:
# context=file.read()
# print(context)
# with open ("regex.txt" ,'r+') as file:
# file.write("line1")
# file.write("\n line 2")
# file.write("\n line 3")
# file.write("\n line 4")
# file.write("/n line 2")
# file.seek(2)
# print(file.read())
# with open ("regex2.txt" ,'r+') as file:
# file.write("line1")
# file.write("\n line 2")
# file.write("\n line 3")
# file.write("\n line 4")
# # file.write("/n line 2")
# file.seek(2)
# print(file.read())
# with open ("regex.txt" , 'r+') as file:
# print("position of your pointer is :" ,file.tell())
# print (file.read())
# with open ("regex.txt" , 'x')as file:
# print("the file is creat")
"""list comprehension"""
# data = list(map(int,input().split(" ")))
# print(data)
# data1 = [1,2,3,4]
# data = [2*i for i in range(1,11)]
# print(data)
# data1 = [1,2,3,4]
# data = [f'*{i**2}*' for i in data1]
# print(data)
# data1 = [1,2,3,4]
# data = [f"{'*' * i,i**2 , '*' * i} " for i in data1]
# print(data)
# data =[x+y for x in range(3,5)for y in range(1,3)]
# print(data)
# data1 = [[1,2],[3,4],[5,6]]
# data = [i for i in data1 for i in i ]
# print (data)
# list = ['abc',23,'xyz',90]
# data =[x for x in list if type(x)== int]
# print(data)