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

PYTHON 5 (1)

The document contains two Python scripts that validate user input. The first script checks if a phone number and email ID are valid using regular expressions, while the second script validates a password based on specific criteria. Both scripts provide feedback on the validity of the inputs entered by the user.

Uploaded by

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

PYTHON 5 (1)

The document contains two Python scripts that validate user input. The first script checks if a phone number and email ID are valid using regular expressions, while the second script validates a password based on specific criteria. Both scripts provide feedback on the validity of the inputs entered by the user.

Uploaded by

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

Name :- Sneha Gaikwad

Roll no :- 08

Experiement no. 5

Aim:- Write a Python script that prompts the user to enter their phone number and email ID. It then
employs Regular
dard phone number and email address formats

Code:-

import re

phone_pattern = re.compile(r'^\+?\d{10,15}$')
email_pattern = re.compile(r'^[\w. -]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$')

phone = input("Enter your phone number: ")


email = input("Enter your email ID: ")

if phone_pattern.match(phone):
print("Valid phone number")
else:
print("Invalid phone number")

if email_pattern.match(email):
print("Valid email ID")
else:
print("Invalid email ID")

Output :-

Enter your phone number: 8308164701


Enter your email ID: varung5239@gmai.com
Valid phone number
Valid email ID

Name :- Varunn Nitin Gurav


Roll no :- 14

Experiement no. 5

Aim:- Write a Python script that prompts the user to enter apassword. Use regular expressions to validate
the password based on these
Criteria : Atleast 8 characters long, Contains at least one uppercase letter, one lowercase
letter, onedigit, and one special character

Code :-

import re

def check_password_strength(password):

pattern = re.compile(r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$')
return bool(pattern.match(password))

password = input("Enter your password: ")

if check_password_strength(password):
print("Strong password")
else:
print("Weak password. Must be at least 8 characters long, include uppercase, lowercase, digit, and
special character.")

Output :-

Enter your password: Hello@world13


Strong password

You might also like