DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
Worksheet 1
Student Name: Vivek Anand UID: 23BCS11598
Branch: CSE Section/Group: 702/B
Semester: 3rd Date of Performance: 8|8|24
Subject Name: Python Programming Subject Code: 23CSP-201
1. Aim: Write a python program to create a Simple Password
Validator. The password should meet the following criteria:
At least 8 characters long
Contains at least one uppercase character
Contains at least one number
Accept the password input from user. Provide feedback on
whether the password is valid or not. Also, allow multiple
password checks in one session.
Conditions:
(i) Use logical operators to combine multiple conditions.
(ii) Implement a loop to allow multiple password checks.
(iii) Use if-else statements for validation feedback.
Expected Output :
(i) Prompt for password input
(ii) Feedback on password validity
2. Requirements (Hardware/Software): Integrated
Development Environment (IDLE), Personal Computer
3. Code:
def searchUpper(s):
for i in s:
if(i>="A" and i<="Z"):
return 1
return 0
def searchNum(s):
for i in s:
if(i>="0" and i<="9"):
return 1
return 0
choice=1
password=""
while(choice!=2):
choice=int(input("1 : For password check 2 : EXIT : "))
if(choice!=1 and choice!=2):
print("Wrong input")
elif(choice==2):
print("EXITED SUCCESSFULLY")
else:
password=(input("Enter the password : "))
if(len(password)<8):
print("Password length is shorter! Use at least 8
characters.")
elif(not(searchUpper(password))):
print("Password should at least have one uppercase
character!")
elif(not(searchNum(password))):
print("Password should have at least one number")
else:
print("Your password is valid!")
4. Output:
5. Learning Outcome:
5.1 Learnt to use the basic syntax of python
5.2 Learnt various loops and its iterations
5.3 Learnt using functions, logical operators
5.4 Learnt operating conditional (if-else) statements