0% found this document useful (0 votes)
16 views23 pages

Documents 12-28 081644

This document is a project report certificate for a student from Kendriya Vidyalaya, Jhunjhunu, certifying the completion of a project under the guidance of a teacher. It includes an index of sections such as introduction, hardware requirements, source code, code explanation, and screenshots. The source code demonstrates user authentication, data manipulation, and visualization using Python with libraries like pandas and matplotlib.

Uploaded by

Aditya Janu
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)
16 views23 pages

Documents 12-28 081644

This document is a project report certificate for a student from Kendriya Vidyalaya, Jhunjhunu, certifying the completion of a project under the guidance of a teacher. It includes an index of sections such as introduction, hardware requirements, source code, code explanation, and screenshots. The source code demonstrates user authentication, data manipulation, and visualization using Python with libraries like pandas and matplotlib.

Uploaded by

Aditya Janu
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/ 23

CERTIFICATE

This is to certify that ……………………………


of
Class xii, of kendriya vidalaya, jhunjhunu
Has completed this project report under the
guidance of
Mr. losek saini during the academic year 2024-
25.

Signature of the teacher:

Signature of the student:


INDEX
1. INTRODUCATION.
2.HARD WARE REQUERMENT.
3.SOURCE CODE.
4.CODE EXPLAIN.
5.SCREENSHOT.
6.BIBLIOGRAPHY.
HARDWARE
REQUIREMENT
&
Software Requirement

Hardware Requirement
PC/Laptop/MacBook with
Intel core/i3/i5/i7 or any equivalent
With at least 2 GB RAM
10 MB free space on Hard Disk
LCD/LED

Operating System & Compiler


MS Windows/Ubuntu/MacOS

Python IDLE 3.x


Source
Code

import pandas as pd
import matplotlib.pyplot as plt

# Dummy data for demonstration


def create_dataframe():
data = {
'Name': ['Alice', 'Bob', 'Charlie', 'David'],
'Age': [25, 30, 35, 40],
'Salary': [50000, 60000, 70000, 80000],
}
df = pd.DataFrame(data)
return df

def plot_data(df):
# Visualize salary distribution
plt.figure(figsize=(8, 6))
plt.bar(df['Name'], df['Salary'], color='skyblue')
plt.title('Salary Distribution', fontsize=16)
plt.xlabel('Name', fontsize=12)
plt.ylabel('Salary', fontsize=12)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()

def authenticate(users):
while True:
print("Welcome to the Data Center!")
user_name = input("Enter your name: ")

if user_name not in users:


print("Error: Name not recognized. Try again.")
continue # Restart loop if name is not recognized

user_password = input("Enter your password: ")


if user_password != users[user_name]:
print("Error: Incorrect password. Try again.")
continue # Restart loop if password is incorrect

print(f"Login successful! Welcome, {user_name}!")


break # Exit the loop upon successful login

def add_entry(df):
name = input("Enter name: ")
age = int(input("Enter age: "))
salary = float(input("Enter salary: "))
new_entry = {'Name': name, 'Age': age, 'Salary': salary}
df = df.append(new_entry, ignore_index=True)
print(f"Added entry: {new_entry}")
return df

def delete_entry(df):
name_to_delete = input("Enter the name of the person to delete: ")
if name_to_delete in df['Name'].values:
df = df[df['Name'] != name_to_delete]
print(f"Deleted entry with name: {name_to_delete}")
else:
print(f"No entry found with name: {name_to_delete}")
return df

def update_entry(df):
name_to_update = input("Enter the name of the person to update: ")
if name_to_update in df['Name'].values:
index = df[df['Name'] == name_to_update].index[0]
print(f"Updating entry for {name_to_update}:")
new_age = int(input("Enter new age: "))
new_salary = float(input("Enter new salary: "))
df.at[index, 'Age'] = new_age
df.at[index, 'Salary'] = new_salary
print(f"Updated entry: {df.loc[index]}")
else:
print(f"No entry found with name: {name_to_update}")
return df

def view_data(df):
print("\nCurrent Dataframe:")
print(df)

def main():
# Define allowed users and their passwords
users = {"Avnish Nunia": "avnish123",
"Aditya Raj": "aditya456",
"Aditya Janu": "aditya789"}

# Authenticate the user


authenticate(users)

# Create initial data


df = create_dataframe()

while True:
print("\nOptions:")
print("1. View Data")
print("2. Add Entry")
print("3. Delete Entry")
print("4. Update Entry")
print("5. Visualize Data")
print("6. Exit")

choice = input("Enter your choice: ")

if choice == "1":
view_data(df)
elif choice == "2":
df = add_entry(df)
elif choice == "3":
df = delete_entry(df)
elif choice == "4":
df = update_entry(df)
elif choice == "5":
plot_data(df)
elif choice == "6":
print("Exiting the Data Center. Goodbye!")
print("Made By Avnish Nunia, Aditya Janu and Aditya Raj.")
break
else:
print("Invalid choice. Please try again.")

if __name__ == "__main__":
main()

Code
Explanation
Import Libraries
import pandas as pd import matplotlib.pyplot as plt
· pandas: Used for data manipulation and analysis. In this program, it's used to
create and manage a DataFrame.
· matplotlib.pyplot: Used for data visualization. It creates the bar chart for the
salary distribution.
Dummy Data Creation
def create_dataframe():
data = {
'Name': ['Alice', 'Bob', 'Charlie', 'David'],
'Age': [25, 30, 35, 40],
'Salary': [50000, 60000, 70000, 80000],
}
df = pd.DataFrame(data)
return df
· Creates a dictionary with data about employees: their names, ages, and
salaries.
· Converts this dictionary into a pandas DataFrame.
· Returns the DataFrame, which will act as the core data structure for this
program.
Plotting Data
def plot_data(df):
plt.figure(figsize=(8, 6))
plt.bar(df['Name'], df['Salary'], color='skyblue')
plt.title('Salary Distribution', fontsize=16)
plt.xlabel('Name', fontsize=12)
plt.ylabel('Salary', fontsize=12)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()
· plt.figure(): Creates a figure with specified dimensions (8x6 inches).
· plt.bar(): Plots a bar chart with names on the x-axis and salaries on the y-axis.
· Styling:
o Adds a title and labels for x and y axes.
o Adds gridlines for better readability.
· plt.show(): Displays the chart to the user.
User Authentication
def authenticate(users):
while True:
print("Welcome to the Data Center!")
user_name = input("Enter your name: ")

if user_name not in users:


print("Error: Name not recognized. Try again.")
continue

user_password = input("Enter your password: ")

if user_password != users[user_name]:
print("Error: Incorrect password. Try again.")
continue
print(f"Login successful! Welcome, {user_name}!")
break
1. Takes a dictionary userscontaining allowed usernames and passwords.
2. while True: Ensures the program remains in the authentication loop until
valid credentials are provided.
3. Checks if the entered name exists in the usersdictionary.
o If not, it prompts again.
4. Validates the password corresponding to the username.
o If the password is incorrect, it prompts again.
5. Once both name and password are validated, the user is welcomed, and the
loop exits.
Add an Entry
def add_entry(df):
name = input("Enter name: ")
age = int(input("Enter age: "))
salary = float(input("Enter salary: "))
new_entry = {'Name': name, 'Age': age, 'Salary': salary}
df = df.append(new_entry, ignore_index=True)
print(f"Added entry: {new_entry}")
return df
· Prompts the user to input a new entry's name, age, and salary.
· Creates a dictionary (new_entry) for the new row.
· df.append(): Adds the new entry to the DataFrame.
· Returns the updated DataFrame.
Delete an Entry
def delete_entry(df):
name_to_delete = input("Enter the name of the person to delete: ")
if name_to_delete in df['Name'].values:
df = df[df['Name'] != name_to_delete]
print(f"Deleted entry with name: {name_to_delete}")
else:
print(f"No entry found with name: {name_to_delete}")
return df
· Asks for the name of the person to delete.
· Checks if the name exists in the DataFrame.
· Deletes the row: Keeps all rows except the one with the specified name using
filtering.
· If the name doesn't exist, it shows an error message.
Update an Entry
def update_entry(df):
name_to_update = input("Enter the name of the person to update: ")
if name_to_update in df['Name'].values:
index = df[df['Name'] == name_to_update].index[0]
print(f"Updating entry for {name_to_update}:")
new_age = int(input("Enter new age: "))
new_salary = float(input("Enter new salary: "))
df.at[index, 'Age'] = new_age
df.at[index, 'Salary'] = new_salary
print(f"Updated entry: {df.loc[index]}")
else:
print(f"No entry found with name: {name_to_update}")
return df
· Finds the row corresponding to the name provided.
· Updates the Ageand Salarycolumns with new values.
· If the name is not found, it displays an error message.
View the Data
def view_data(df): print("\nCurrent Dataframe:") print(df)
· Displays the current state of the DataFrame.
Main Function
def main():
users = {
"Avnish Nunia": "avnish123",
"Aditya Raj": "aditya456",
"Aditya Janu": "aditya789"
}
authenticate(users)
df = create_dataframe()

while True:
print("\nOptions:")
print("1. View Data")
print("2. Add Entry")
print("3. Delete Entry")
print("4. Update Entry")
print("5. Visualize Data")
print("6. Exit")

choice = input("Enter your choice: ")

if choice == "1":
view_data(df)
elif choice == "2":
df = add_entry(df)
elif choice == "3":
df = delete_entry(df)
elif choice == "4":
df = update_entry(df)
elif choice == "5":
plot_data(df)
elif choice == "6":
print("Exiting the Data Center. Goodbye!")
print("Made By Avnish Nunia, Aditya Janu and Aditya Raj.")
break
else:
print("Invalid choice. Please try again.")
break else:
print("Invalid choice. Please try again.")
· User Authentication: Calls authenticate()to ensure only valid users can
proceed.
· Creates the initial DataFrame using create_dataframe().
· Offers a menu of options for interacting with the DataFrame.
Run the Program
if __name__ == "__main__": main()
· Ensures the main()function runs only when the script is executed directly.
Screenshot
s
Authentication Process

When you run the script, it will prompt for a username and password.

Example:

If you enter an incorrect name or password, it will keep asking until you provide
the correct credentials.
Options:

Option 1: View Data

After successful login, the main menu will appear:

Options:

Output Example:
Option 2: Add Entry

Choose option 2 to add a new entry

Output:

The updated data will now include Ethan.

Option 3: Delete Entry


Choose option 3 to delete an entry by name:

Output:

Option 4: Update Entry

Choose option 4 to update someone’s data:


Output:

Option 5: Visualize Data

Choose option 5 to generate a bar chart of salaries:

Output:
Option 6: Exit

Choose option 6 to exit the program:


Output:

You might also like