0% found this document useful (0 votes)
3 views9 pages

ACSBR Timetable and Password Checker

The document outlines two programming problems: a password checker and a timetable query system. The password checker validates user-entered passwords against specific security criteria, while the timetable system allows users to query class schedules based on day and time or subject. Both projects are implemented in Python, demonstrating basic programming concepts and user input handling.

Uploaded by

chetanreddy1408
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)
3 views9 pages

ACSBR Timetable and Password Checker

The document outlines two programming problems: a password checker and a timetable query system. The password checker validates user-entered passwords against specific security criteria, while the timetable system allows users to query class schedules based on day and time or subject. Both projects are implemented in Python, demonstrating basic programming concepts and user input handling.

Uploaded by

chetanreddy1408
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

Chanakya University

School of Engineering
EES111- Problem Solving using Programming

Problem 2: Password Checker

Objective: The objective of this code is to validate whether a user-entered password


meets specific security criteria. It checks that the password:

1. Has a length between 8 and 16 characters.


2. Includes at least one uppercase letter.
3. Includes at least one lowercase letter.
4. Contains at least one digit.
5. Contains at least one special character from a defined set (!|@?$).

Project description & Explanation:

When we run, the program prompts the user to enter a password. It then
evaluates the input using the check_password method and prints whether the
password is valid or specifies why it is [Link] project is a simple Python
program that checks whether a user-entered password meets specific security
standards. It defines a PasswordChecker class with rules that ensure the
password is between 8 and 16 characters long and includes at least one
uppercase letter, one lowercase letter, one digit, and one special character from
the set !|@?$. It begins by checking the length to ensure it falls within the
allowed range. After that, it checks whether the password contains at least one
uppercase letter, one lowercase letter, one number, and one of the defined
special characters. If the password meets all these criteria, the program prints
“Valid password!” Otherwise, it prints an error message explaining why the
password is invalid.
CODE:

class PasswordChecker:

def __init__(self):

self.special_characters = ["!","|","@","?","$"]

self.min_length = 8

self.max_length = 16

def check_password(self, password):

# Check length

if len(password) < self.min_length or len(password) > self.max_length:

return "Invalid: Password length must be between 8 and 16 characters."

# Check for required components

has_upper = any([Link]() for char in password)

has_lower = any([Link]() for char in password)

has_digit = any([Link]() for char in password)

has_special = any(char in self.special_characters for char in password)

if all((has_upper, has_lower, has_digit, has_special)):

return "Valid password!"

else:

return "Invalid: Password must include upper and lower case letters,
digits, and special characters."
checker = PasswordChecker()

print(checker.check_password(input("Enter your password: ")))


Problem 1: Create a timetable that answers Query
Objective: To write a code where it answers a query given by the user
based on the timetable. If the user gives a specific day and time. The
code checks the timetable gives out the class on that specific time of
the day.

Code:
#first we are entering the timetable of the class in the form of a list which
contains dictionry which contain the time table

timetable = [

# Monday

{"day": "Monday", "time": "9:30", "subject": "statics and probability",


"room": "IB07", "teacher": "Vijay Sir"},

{"day": "Monday", "time": "10:30", "subject": "statics and probability",


"room": "IB07", "teacher": "Vijay Sir"},

{"day": "Monday", "time": "11:45", "subject": "chemistry lab", "room":


"Lab(B1)", "teacher": "Akhila Mam"},

{"day": "Monday", "time": "12:45", "subject": "chemistry lab", "room":


"Lab(B1)", "teacher": "Akhila Mam"},

{"day": "Monday", "time": "2:50", "subject": "HSS elective", "room":


"room 122", "teacher": "Rajashri mam"},

{"day": "Monday", "time": "3:50", "subject": "HSS elective", "room":


"room 122", "teacher": "Rajashri mam"},

# Tuesday

{"day": "Tuesday", "time": "9:30", "subject": "programming for problem


solving", "room": "Lab", "teacher": "Kiran Sir"},

{"day": "Tuesday", "time": "10:30", "subject": "programming for


problem solving", "room": "Lab", "teacher": "Kiran Sir"},
{"day": "Tuesday", "time": "11:45", "subject": "HSS elective", "room":
"room 122", "teacher": "Rajashri mam"},

{"day": "Tuesday", "time": "12:45", "subject": "IDT", "room": "IB07",


"teacher": "Shree Hari Sir"},

{"day": "Tuesday", "time": "2:50", "subject": "chemistry", "room":


"IB07", "teacher": "Akhila Mam"},

{"day": "Tuesday", "time": "3:50", "subject": "chemistry", "room":


"IB07", "teacher": "Akhila Mam"},

# Wednesday

{"day": "Wednesday", "time": "9:30", "subject": "IDT lab", "room":


"Computer Center", "teacher": "Amish Sir"},

{"day": "Wednesday", "time": "10:30", "subject": "IDT lab", "room":


"Computer Center", "teacher": "Amish Sir"},

{"day": "Wednesday", "time": "11:45", "subject": "buffer class", "room":


"IB07", "teacher": "Some Teacher"},

{"day": "Wednesday", "time": "12:45", "subject": "buffer class", "room":


"IB07", "teacher": "Some Teacher"},

{"day": "Wednesday", "time": "2:50", "subject": "engineering


mechanics", "room": "IB07", "teacher": "Naresh Sir"},

{"day": "Wednesday", "time": "3:50", "subject": "engineering


mechanics", "room": "IB07", "teacher": "Naresh Sir"},

# Thursday

{"day": "Thursday", "time": "9:30", "subject": "environmental studies",


"room": "IB07", "teacher": "Visiting faculty"},

{"day": "Thursday", "time": "10:30", "subject": "none", "room": "IB07",


"teacher": "none"},

{"day": "Thursday", "time": "11:45", "subject": "none", "room": "IB07",


"teacher": "none"},

{"day": "Thursday", "time": "12:45", "subject": "none", "room": "IB07",


"teacher": "none"},

{"day": "Thursday", "time": "2:50", "subject": "club activities", "room":


"IB07", "teacher": "assigned faculty"},
{"day": "Thursday", "time": "3:50", "subject": "club activities", "room":
"IB07", "teacher": "assigned faculty"},

# Friday

{"day": "Friday", "time": "9:30", "subject": "engineering mechanics",


"room": "IB07", "teacher": "Naresh Sir"},

{"day": "Friday", "time": "10:30", "subject": "programming for problem


solving", "room": "IB07", "teacher": "Srikanth Sir"},

{"day": "Friday", "time": "11:45", "subject": "programming for problem


solving", "room": "IB07", "teacher": "Srikanth Sir"},

{"day": "Friday", "time": "12:45", "subject": "none", "room": "IB07",


"teacher": "none"},

{"day": "Friday", "time": "2:50", "subject": "none", "room": "IB07",


"teacher": "none"},

{"day": "Friday", "time": "3:50", "subject": "none", "room": "IB07",


"teacher": "none"},

# Saturday

{"day": "Saturday", "time": "9:30", "subject": "probability and statics",


"room": "IB07", "teacher": "Vijay Nair"},

{"day": "Saturday", "time": "10:30", "subject": "probability and statics",


"room": "IB07", "teacher": "Vijay Nair"},

{"day": "Saturday", "time": "11:45", "subject": "chem lab", "room":


"Lab(B1)", "teacher": "Akhila"},

{"day": "Saturday", "time": "12:45", "subject": "chem lab", "room":


"Lab(B1)", "teacher": "Akhila"},

{"day": "Saturday", "time": "2:50", "subject": "engineering mechanics",


"room": "IB07", "teacher": "Naresh Sir"},

{"day": "Saturday", "time": "3:50", "subject": "engineering mechanics",


"room": "IB07", "teacher": "Naresh Sir"}

def day_time_given(day, time):#this is the function which helps us find


the subject in the time table
for i in timetable:#each dictionary in the list

if i["day"].upper() == [Link]() and i["time"] == time: #it will


search for the day key and find its value in the dictionary and convert it to
upper case and match it with day in the function parameter similarly for
the time

print("Subject:", i["subject"]) #if the upper condition is true the it


will print the value of subject of the same dictionary

print("Room:", i["room"]) #the value of room

print("Teacher:", i["teacher"])#the value of teacher

def subject_given(subject): #this will give you the day and the time and
teacher id the subject is given

for i in timetable:#each dictionary in the list

if i["subject"].upper() == [Link]():#it will take the value of


the subject and conert it to upper and copare with the parameter of the
function which is converted to upper case

print("day:", i["day"]) #it will print out the day value of the same
dictionary

print("time:", i["time"])#it will print out the time value of the same
dictionary

print("teacher:",i["teacher"])#it will print out the teacher value of


the same dictionary

def running():

query = input("Ask your question (e.g., 'Class on Monday at 9:30' or


'When is chemistry lab'):\n").lower()# "class on monday at 9:30" and
"when is chemistry lab" is the query

if "class on" in query and "at" in query: #ckecking is word "class on"
and "at" are ther in the query

parts = [Link]("class on")#his is goint to give you eg.['', '


monday at 9:30'] so you can take tha day and time

if len(parts) > 1 and "at" in parts[1]: #this goingto check ifyou have
more that one element in the list and if the there is thenit will check ifther
is at in the 2nd element

sub_parts = parts[1].split("at") #it is going to split the second


element of the lst at "at"
if len(sub_parts) == 2:#it is checking is if the len of 2nd list is 2
eg.['monday','9:30']

day = sub_parts[0].strip().capitalize() #it will take 'monday' and


remove spaces and capitalize

time = sub_parts[1].strip()#will take '9:30'and strip

day_time_given(day, time)#it will set the parameter as the


above 2 coments

return

print("Couldn't parse day and time properly.")#if the "class on" and
"at" are not there then it will show tis error

# Handle "when is [subject]"

elif [Link]("when is"):#check if the query is vaild by checking


if "when is " is there

subject = [Link]("when is", "").strip()#this will remove "when


is "and stripn will remove the spaces

if subject:#checks if there is something inthe variable and if it is


there itwill printrhe following statements

subject_given(subject) #calling the function

return

print("Please specify a subject after 'when is'.")#the error if the


subject variable has nothing inside

else:

print("Sorry, I couldn't understand your question.")#error if the query


is not valid

running()

You might also like