-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab_5.py
More file actions
59 lines (52 loc) · 1.39 KB
/
lab_5.py
File metadata and controls
59 lines (52 loc) · 1.39 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
#zero division error
try:
a=int(input("Enter 1st number"))
b=int(input("Enter 2nd number"))
c=a/b
print(c)
except ZeroDivisionError as error:
print(error)
#used the finally and raise keyword in this
try:
arr1=["kavaskar","mca",1,2]
print(arr1[4])
print(arr1[3])
a=int(input("Enter 1st number"))
b=int(input("Enter 2nd number"))
if(b==0):
raise ZeroDivisionError("ZeroDivisionError")
else:
print(a/b)
except IndexError as e:
print(e)
finally:
print("The code ran successfully")
#
import re
def func1(text):
pattern1=r'[(?][0-9]{3}[)?]\-[0-9]{3}\-[0-9]{4}'
pattern2=r'[0-9]{3}\-[0-9]{3}\-[0-9]{4}'
match1=re.search(pattern1,text)
match2=re.search(pattern2,text)
if match1 or match2:
print("Valid phn number")
else:
print("Invalid phn number")
text=str(input("Enter the string"))
func1(text)
import re
def func1(text):
pattern2=r'[A-Z]+'
pattern3=r'[a-z]+'
pattern4=r'[0-9]+'
pattern5=r'[@ - / , .]+'
match2=re.search(pattern2,text)
match3=re.search(pattern3,text)
match4=re.search(pattern4,text)
match5=re.search(pattern5,text)
if match2 and match3 and match4 and match5:
print("Password Set Successfully")
else:
print("Set a Valid Password")
text=str(input("Enter the string"))
func1(text)