0% found this document useful (0 votes)
34 views2 pages

Python Programs

Uploaded by

prajyotekatpure
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views2 pages

Python Programs

Uploaded by

prajyotekatpure
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Python Programs with Outputs

PROGRAM 1: Password Validator


import re

passwords = ["ABd1234@1", "F1#,2w3E*", "2We3345"]

for password in passwords:


if 6 <= len(password) <= 12:
if (re.search("[a-z]", password) and
re.search("[A-Z]", password) and
re.search("[0-9]", password) and
re.search("[$#@]", password)):
print(f"{password} => VALID")
else:
print(f"{password} => INVALID")
else:
print(f"{password} => INVALID")

Output:
ABd1234@1 => VALID
F1#,2w3E* => VALID
2We3345 => INVALID

PROGRAM 2: Email Domain Extractor


emails = input("Enter an Email: ")
email_list = emails.split(",")
domains = {}

for email in email_list:


domain = email.strip().split('@')[-1]
if domain in domains:
domains[domain] += 1
else:
domains[domain] = 1

for domain, count in domains.items():


print(f"{domain}: {count}")

Sample Input:
Enter an Email: [email protected], [email protected], [email protected], [email protected], [email protected]
Output:
gmail.com: 2
yahoo.com: 2
outlook.com: 1

PROGRAM 3: Vehicle Registration Number Validator


import re

numbers = ["MH12AB1234", "KA01AA0007", "P12A1234", "MH123WA4567", "21BH2506AA", "21BH2369IK"]

for number in numbers:


case1 = re.fullmatch(r"[A-Z]{2}[0-9]{2}[A-Z]{2}[0-9]{4}", number)
case2 = re.fullmatch(r"[0-9]{2}BH[0-9]{4}[A-HJ-NP-Z]{2}", number)
if case1 or case2:
print(f"{number} is Valid Number")
else:
print(f"{number} is Invalid Number")

Output:
MH12AB1234 is Valid Number
KA01AA0007 is Valid Number
P12A1234 is Invalid Number
MH123WA4567 is Invalid Number
21BH2506AA is Valid Number
21BH2369IK is Invalid Number

You might also like