IPP Assignment
IPP Assignment
existing_items = selected_items_var.get()
new_item = f"{item} x{quantity}"
root = Tk()
root.title("Vipin's Restaurant Bill System")
background_image = PhotoImage(file="background_image.png")
background_label = Label(root, image=background_image)
background_label.place(relwidth=1, relheight=1)
menu_prices = {
"Dosa": 50.00,
"Iddli": 35.00,
"Samosa": 20.00,
"Burger": 80.00,
"Veg Puff": 30.00,
"Dhokla": 45.00,
___________________________________________________________________________
Course Instructor Examiner (s)
Name: Dr. Gajanan M Naik Name:
Signature: Signature:
RV Institute of Technology and Management, Bengaluru
Information Science and Engineering
Introduction to Python Programming
Assignment I
____________________________________________________________
"Chole Bhature": 60.00,
"Kachodi": 35.00,
"Veg Roll": 40.00,
"Sandwich": 30.00,
"Coke": 20.00
}
selected_items_var = StringVar()
total_cost_var = StringVar()
row_num = 1
for item in menu_prices:
item_label = Label(root, text=item, bg="white")
item_label.grid(row=row_num, column=0, padx=10, pady=5, sticky=W)
quantity_entry = Entry(root)
quantity_entry.grid(row=row_num, column=1, padx=10, pady=5, sticky=W)
row_num += 1
___________________________________________________________________________
Course Instructor Examiner (s)
Name: Dr. Gajanan M Naik Name:
Signature: Signature:
RV Institute of Technology and Management, Bengaluru
Information Science and Engineering
Introduction to Python Programming
Assignment I
____________________________________________________________
root.mainloop()
___________________________________________________________________________
Course Instructor Examiner (s)
Name: Dr. Gajanan M Naik Name:
Signature: Signature:
RV Institute of Technology and Management, Bengaluru
Information Science and Engineering
Introduction to Python Programming
Assignment I
____________________________________________________________
Output_GUI
___________________________________________________________________________
Course Instructor Examiner (s)
Name: Dr. Gajanan M Naik Name:
Signature: Signature:
RV Institute of Technology and Management, Bengaluru
Information Science and Engineering
Introduction to Python Programming
Assignment I
____________________________________________________________
Program: 02-
Creating a Voting System using Python GUI
Program Code:
import tkinter as tk
from tkinter import messagebox
class VotingSystem:
def __init__(self, master):
self.master = master
self.master.title("Election Voting System")
self.voters = []
self.party_votes = {"BJP": 0, "Congress": 0, "JD(S)": 0}
self.name_entry = tk.Entry(master)
self.name_entry.pack()
self.voter_id_entry = tk.Entry(master)
self.voter_id_entry.pack()
___________________________________________________________________________
Course Instructor Examiner (s)
Name: Dr. Gajanan M Naik Name:
Signature: Signature:
RV Institute of Technology and Management, Bengaluru
Information Science and Engineering
Introduction to Python Programming
Assignment I
____________________________________________________________
self.selected_party = tk.StringVar()
self.vote_count = 0
self.max_votes = 10
def cast_vote(self):
if self.vote_count < self.max_votes:
name = self.name_entry.get()
voter_id = self.voter_id_entry.get()
selected_party = self.selected_party.get()
self.vote_count += 1
self.clear_entries()
if self.vote_count == self.max_votes:
self.show_results()
else:
self.show_error("Please fill in all the details.")
else:
self.show_error("Voting has ended. Results will be displayed.")
def clear_entries(self):
self.name_entry.delete(0, tk.END)
self.voter_id_entry.delete(0, tk.END)
self.selected_party.set("")
def show_results(self):
winner = max(self.party_votes, key=self.party_votes.get)
winner_votes = self.party_votes[winner]
if len(tie) > 1:
loser = min(self.party_votes, key=self.party_votes.get)
result_message = f"There is a tie! Mentioning the party with the least votes: {loser}"
else:
___________________________________________________________________________
Course Instructor Examiner (s)
Name: Dr. Gajanan M Naik Name:
Signature: Signature:
RV Institute of Technology and Management, Bengaluru
Information Science and Engineering
Introduction to Python Programming
Assignment I
____________________________________________________________
result_message = f"The winner is {winner} with {winner_votes} votes!"
if __name__ == "__main__":
root = tk.Tk()
voting_system = VotingSystem(root)
root.mainloop()
___________________________________________________________________________
Course Instructor Examiner (s)
Name: Dr. Gajanan M Naik Name:
Signature: Signature:
RV Institute of Technology and Management, Bengaluru
Information Science and Engineering
Introduction to Python Programming
Assignment I
____________________________________________________________
Output_GUI
___________________________________________________________________________
Course Instructor Examiner (s)
Name: Dr. Gajanan M Naik Name:
Signature: Signature:
RV Institute of Technology and Management, Bengaluru
Information Science and Engineering
Introduction to Python Programming
Assignment I
____________________________________________________________
Program: 03-
Creating a Calculator using Python GUI
Program Code:
from tkinter import *
def button_click(symbol):
current = entry.get()
entry.delete(0, END)
entry.insert(END, current + str(symbol))
def clear_entry():
entry.delete(0, END)
def calculate_result():
try:
result = eval(entry.get())
entry.delete(0, END)
entry.insert(END, result)
except Exception as e:
entry.delete(0, END)
entry.insert(END, "Error")
window = Tk()
window.title('''Vipin's Calculator''')
window.configure(bg='#2E3B4E')
___________________________________________________________________________
Course Instructor Examiner (s)
Name: Dr. Gajanan M Naik Name:
Signature: Signature:
RV Institute of Technology and Management, Bengaluru
Information Science and Engineering
Introduction to Python Programming
Assignment I
____________________________________________________________
buttons = [
('7', 1, 0), ('8', 1, 1), ('9', 1, 2), ('/', 1, 3),
('4', 2, 0), ('5', 2, 1), ('6', 2, 2), ('*', 2, 3),
('1', 3, 0), ('2', 3, 1), ('3', 3, 2), ('-', 3, 3),
('0', 4, 0), ('.', 4, 1), ('=', 4, 2), ('+', 4, 3),
]
___________________________________________________________________________
Course Instructor Examiner (s)
Name: Dr. Gajanan M Naik Name:
Signature: Signature:
RV Institute of Technology and Management, Bengaluru
Information Science and Engineering
Introduction to Python Programming
Assignment I
____________________________________________________________
clear_button.grid(row=5, column=0, columnspan=4, sticky='nsew')
for i in range(5):
window.grid_rowconfigure(i, weight=1)
window.grid_columnconfigure(i, weight=1)
window.mainloop()
___________________________________________________________________________
Course Instructor Examiner (s)
Name: Dr. Gajanan M Naik Name:
Signature: Signature:
RV Institute of Technology and Management, Bengaluru
Information Science and Engineering
Introduction to Python Programming
Assignment I
____________________________________________________________
Output_GUI
___________________________________________________________________________
Course Instructor Examiner (s)
Name: Dr. Gajanan M Naik Name:
Signature: Signature:
RV Institute of Technology and Management, Bengaluru
Information Science and Engineering
Introduction to Python Programming
Assignment I
____________________________________________________________
Program: 04-
Creating a Student Attendance System using Python GUI
Program Code:
from tkinter import *
from tkinter import messagebox
from tkinter import ttk
class AttendanceApp:
def __init__(self, master):
self.master = master
master.title("Student Attendance")
style = ttk.Style()
style.configure("TLabel", background="#E1DADA")
style.configure("TRadiobutton", background="#E1DADA")
style.configure("TButton", background="#00796B", foreground="white",
font=('Helvetica', 10))
self.frame = ttk.Frame(master)
self.frame.grid(row=0, column=0, columnspan=3, pady=10)
___________________________________________________________________________
Course Instructor Examiner (s)
Name: Dr. Gajanan M Naik Name:
Signature: Signature:
RV Institute of Technology and Management, Bengaluru
Information Science and Engineering
Introduction to Python Programming
Assignment I
____________________________________________________________
self.canvas = Canvas(self.frame, yscrollcommand=scrollbar.set)
self.canvas.grid(row=0, column=0, columnspan=3)
scrollbar.config(command=self.canvas.yview)
scrollbar.grid(row=0, column=3, sticky="ns")
def submit_attendance(self):
___________________________________________________________________________
Course Instructor Examiner (s)
Name: Dr. Gajanan M Naik Name:
Signature: Signature:
RV Institute of Technology and Management, Bengaluru
Information Science and Engineering
Introduction to Python Programming
Assignment I
____________________________________________________________
if __name__ == "__main__":
root = Tk()
app = AttendanceApp(root)
root.mainloop()
___________________________________________________________________________
Course Instructor Examiner (s)
Name: Dr. Gajanan M Naik Name:
Signature: Signature:
RV Institute of Technology and Management, Bengaluru
Information Science and Engineering
Introduction to Python Programming
Assignment I
____________________________________________________________
Output_GUI
___________________________________________________________________________
Course Instructor Examiner (s)
Name: Dr. Gajanan M Naik Name:
Signature: Signature:
RV Institute of Technology and Management, Bengaluru
Information Science and Engineering
Introduction to Python Programming
Assignment I
____________________________________________________________
Program: 05-
Creating a BMI Calculator using Python GUI
Program Code:
from tkinter import *
def calculate_bmi():
weight = float(weight_entry.get())
height = float(height_entry.get()) / 100
bmi = round(weight / (height ** 2), 2)
result_label.config(text=f'Your BMI: {bmi}')
___________________________________________________________________________
Course Instructor Examiner (s)
Name: Dr. Gajanan M Naik Name:
Signature: Signature:
RV Institute of Technology and Management, Bengaluru
Information Science and Engineering
Introduction to Python Programming
Assignment I
____________________________________________________________
"- Cut down on sugary and high-calorie foods."
else:
category = 'Obese'
suggestion = "It is advisable to consult a healthcare professional for personalized advice.
"\
"In the meantime, focus on a balanced diet and regular physical activity."
show_suggestions(category, suggestion)
window = Tk()
window.title('BMI Calculator')
weight_entry = Entry(window)
___________________________________________________________________________
Course Instructor Examiner (s)
Name: Dr. Gajanan M Naik Name:
Signature: Signature:
RV Institute of Technology and Management, Bengaluru
Information Science and Engineering
Introduction to Python Programming
Assignment I
____________________________________________________________
weight_entry.grid(row=0, column=1, padx=10, pady=10)
height_entry = Entry(window)
height_entry.grid(row=1, column=1, padx=10, pady=10)
window.mainloop()
___________________________________________________________________________
Course Instructor Examiner (s)
Name: Dr. Gajanan M Naik Name:
Signature: Signature:
RV Institute of Technology and Management, Bengaluru
Information Science and Engineering
Introduction to Python Programming
Assignment I
____________________________________________________________
Output_GUI
___________________________________________________________________________
Course Instructor Examiner (s)
Name: Dr. Gajanan M Naik Name:
Signature: Signature: