0% found this document useful (0 votes)
8 views

PYTHON_practical

Uploaded by

A.k Unity world
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

PYTHON_practical

Uploaded by

A.k Unity world
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Python Programming

Skill Based Mini Project Report

Submitted for the partial fulfilment of the degree of

Bachelor of Technology
In
Artificial Intelligence and Machine Learning
Submitted By

ADITYA KUMAR SINGH


0901AM231004
ARMAN SINGH TOMAR
0901AM231013

UNDER THE SUPERVISION AND GUIDANCE OF

Mr. Ashish Singh


(Assistant Professor)
Mr. Khemchand Shakywar
(Assistant Professor)

Centre for Artificial Intelligence

Session 2024-25
DECLARATION BY THE CANDIDATE

We hereby declare that the work entitled “Schema for College Database” is our work,
conducted under the supervision of Mr. Ashish Singh (Assistant Professor) & Mr.
Khemchand Shakywar (Assistant Professor), during the session Aug-Dec 2024. The report
submitted by us is a record of bonafide work carried out by me.

We further declare that the work reported in this report has not been submitted and will not be
submitted, either in part or in full, for the award of any other degree or diploma in this institute
or any other institute or university.

--------------------------------

Aditya Kumar Singh(0901AM231004)


Arman Singh Tomar(0901AM231013)

Date: 21.11.2024
Place: Gwalior

This is to certify that the above statement made by the candidates is correct to the best of our
knowledge and belief.
ACKNOWLEDGEMENT
We would like to express our greatest appreciation to all the individuals who have helped and
supported us throughout this report. We are thankful to the whole Centre for Artificial
Intelligence for their ongoing support during the experiments, from initial advice and provision
of contact in the first stages through ongoing advice and encouragement, which led to the final
report.

A special acknowledgement goes to our colleagues who help us in completing the file and by
exchanging interesting ideas to deal with problems and sharing the experience.

We wish to thank the faculty and supporting staff for their undivided support and interest which
inspired us and encouraged us to go my own way without whom we would be unable to
complete my project.

In the end, We want to thank our friends who displayed appreciation for our work and
motivated us to continue our work.

Aditya Kumar Singh


Arman Singh Tomar
Micro Project:
Write a python program that validates an email ID entered by the user,
where the validation rules include that at least one character should be in
lowercase and one in uppercase and contains at least one numeric character
and one special symbol
INPUT:
import re
def validate_email(email):
# Regular expression to check for required conditions
# 1. At least one lowercase letter: [a-z]
# 2. At least one uppercase letter: [A-Z]
# 3. At least one numeric character: [0-9]
# 4. At least one special symbol: [^a-zA-Z0-9] (non-alphanumeric)
pattern = r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^a-zA-Z0-9]).+$'

if re.match(pattern, email):
print("Valid email ID")
else:
print("Invalid email ID")

print("Name: Aditya Kumar Singh")


print("Enroll: 0901AM231004")
email = input("Enter an email ID to validate: ")
validate_email(email)

OUTPUT:
Macro Project:
Suppose a text file contains information about students in the form of Name,
10th-class exam roll number, marks in physics, marks in chemistry and
marks in mathematics. Write a python script to generate a text file
containing subject-wise merit list
INPUT:
Text File: students.txt
Aadi,0901004,85,78,92
Arman,0901005,91,88,84
PM,0901006,76,82,89
Aditya,0901007,93,79,85

Python Script:
def read_student_data(filename):
students = []
with open(filename, 'r') as file:
for line in file:
if line.strip(): # Skip empty lines
name, roll_number, physics, chemistry, math = line.strip().split(',')
students.append({
'name': name,
'roll_number': roll_number,
'physics': int(physics),
'chemistry': int(chemistry),
'math': int(math)
})
return students
def write_merit_list(students, subject, filename):
sorted_students = sorted(students, key=lambda x: x[subject], reverse=True)

with open(filename, 'w') as file:


file.write(f"Merit list for {subject.capitalize()}:\n")
file.write("Name\tRoll Number\tMarks\n")
for student in sorted_students:
file.write(f"{student['name']}\t{student['roll_number']}\t{student[subject]}\n")
def main():
input_file = 'students.txt'
students = read_student_data(input_file)

# Generate merit lists for each subject


write_merit_list(students, 'physics', 'physics_merit_list.txt')
write_merit_list(students, 'chemistry', 'chemistry_merit_list.txt')
write_merit_list(students, 'math', 'math_merit_list.txt')
print("Merit lists generated successfully!")
if __name__ == "__main__":
main()

OUTPUT:
Mini Project
Create a login module with below mentioned features:
a. Verify username and password correctly
b. Register new user and set its password
c. Change password of any registered user
Note: Store the usernames and passwords in a Dictionary
INPUT:
# Dictionary to store usernames and passwords
users_db = {}

def register_user(username, password):


"""Register a new user with a username and password."""
if username in users_db:
print("Username already exists. Please choose a different username.")
else:
users_db[username] = password
print("User registered successfully!")

def verify_user(username, password):


"""Verify if the username and password match."""
if username in users_db and users_db[username] == password:
print("Login successful!")
else:
print("Invalid username or password.")

def change_password(username, old_password, new_password):


"""Change the password for an existing user."""
if username in users_db and users_db[username] == old_password:
users_db[username] = new_password
print("Password changed successfully!")
else:
print("Invalid username or old password.")
def main():
while True:
print("\n1. Register new user")
print("2. Login")
print("3. Change password")
print("4. Exit")

choice = input("Choose an option: ")

if choice == '1':
username = input("Enter new username: ")
password = input("Enter password: ")
register_user(username, password)

elif choice == '2':


username = input("Enter username: ")
password = input("Enter password: ")
verify_user(username, password)

elif choice == '3':


username = input("Enter username: ")
old_password = input("Enter current password: ")
new_password = input("Enter new password: ")
change_password(username, old_password, new_password)

elif choice == '4':


print("Exiting...")
break

else:
print("Invalid option, please try again.")
if __name__ == "__main__":
main()

OUTPUT

You might also like