Program 1- Password Check
import re
password=input()
f=0
if len(password)<8:
f=1
else:
if not password[0].isalpha():
f=1
if not(re.search("[0-9]",password)):
f=1
if not(re.search("[ !\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]",password)):
f=1
if f==1:
print("Invalid")
else:
print("Valid")
Program 2- Keyboard Letters
import re
a=input()
f=0
if(re.search("[QWERTYUIOPqwertyuiop]",a[0])):
for i in a:
if not (re.search("[QWERTYUIOPqwertyuiop]",i)):
f=1
elif(re.search("[ASDFGHJKLasdfghjkl]",a[0])):
for i in a:
if not (re.search("[ASDFGHJKLasdfghjkl]",i)):
f=1
elif(re.search("[ZXCVBNMzxcvbnm]",a[0])):
for i in a:
if not (re.search("[ZXCVBNMzxcvbnm]",i)):
f=1
if f==1:
print("No")
else:
print("Yes")
Program 3- Distinct Letter
a=input()
a=a.upper()
f=0
for i in a:
if(a.count(i)>1):
f=1
break
if(f==1):
print("bad")
else:
print("Good")
import re
password=input()
f=0
if len(password)<8:
f=1
else:
if not password[0].isalpha():
f=1
if not(re.search("[0-9]",password)):
f=1
if not(re.search("[ !\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]",password)):
f=1
if f==1:
print("Invalid")
else:
print("Valid")
Program 2- Keyboard Letters
import re
a=input()
f=0
if(re.search("[QWERTYUIOPqwertyuiop]",a[0])):
for i in a:
if not (re.search("[QWERTYUIOPqwertyuiop]",i)):
f=1
elif(re.search("[ASDFGHJKLasdfghjkl]",a[0])):
for i in a:
if not (re.search("[ASDFGHJKLasdfghjkl]",i)):
f=1
elif(re.search("[ZXCVBNMzxcvbnm]",a[0])):
for i in a:
if not (re.search("[ZXCVBNMzxcvbnm]",i)):
f=1
if f==1:
print("No")
else:
print("Yes")
Program 3- Distinct Letter
a=input()
a=a.upper()
f=0
for i in a:
if(a.count(i)>1):
f=1
break
if(f==1):
print("bad")
else:
print("Good")
Program 4- Caesar Cipher
a=input()
a=a.rstrip('\r')
a=list(a)
d=int(input())
c=0
j=0
for i in a:
j=ord(i)+d
if j>122:
a[c]=chr(j-26)
else:
a[c]=chr(j)
c+=1
a=''.join(a)
print(a)
Program 5- Time Conversion
a=input()
h=int(a[0:2])
m=int(a[3:5])
s=int(a[6:8])
mer=a[8:10]
if ((h>0 and h<13)and(m>=0 and m<60) and (s>=0 and s<60)and (mer=='AM' or mer=='PM')):
if mer=='PM':
if not h==12:
h=h+12
else:
if h==12:
h=0
print(str("%02d"%h)+':'+str("%02d"%m)+':'+str("%02d"%s))
No comments:
Post a Comment