Project 1 +2 + 3.pdf
Project 1 +2 + 3.pdf
loopAgain = True
while loopAgain:
print()
#Gathering input from the user
number_of_people = int(input("Enter Number of People: ")) #Asking the number of people on
the tour
while True:
elephantChoice = input("Ride Elephants Y/N: ").lower() #Asking if they want to ride
elephants or not
if elephantChoice in ['y','n']:
break #Exit loop if choice in selection
else:
print ("Oops! Please enter Y or N.")
continue #Go back to the start of the loop to ask for input
again
while True:
memberChoice = input("Are you a member? Y/N: ").lower()#Asking if they are members or
not
if memberChoice in ['y' , 'n']:
break #Exit loop if choice in selection
else:
print ("Oops! Please enter Y or N.")
continue #Go back to the start of the loop to ask for input
again
#Calculations
if safariChoice == ("a"): #Calculating price based on type of safari
safariTotal = number_of_people * AdventurePrice
else:
safariTotal = number_of_people * DeluxePrice
Total =(Subtotal - Total_discount ) + taxesDue #Total amount due at the end of the
message
print("\n\n")
again = input("Make another reservation? Y/N: ").lower() #Asking if they want to continue
another transaction
if again != "y": #If y the loop is ran again, if not the loop ends
loopAgain = False
#PROJECT 2
loopAgain = True
import math
#Dictionaries to rental and sale properties
forrent = { "1542 Bartlett #199D" :2183,
"1026 17th St #124A" :1900,
"728 16th St #18M" :2633,
"1010 11th #2D" :3406}
return monthly_payment,total_payments,total_interest
if choice == '1':
showProperties() #Show properties
window = Tk()
window.geometry("500x600")
window.title("Pizza Order Form")
pizzariaImage = PhotoImage (file='Pizzaria2.png')
imgLabel = Label ( window, image = pizzariaImage )
imgLabel.grid( row=0, column=0, columnspan=3)
nameLabel = Label(window,
text='Customer Name:',
font=('Arial', 15))
nameLabel.grid(row=1, column=0, sticky=E, pady=(20,20))
userName = Entry(window)
userName.grid(row=1, column=1, columnspan = 2, sticky=W)
smallRadio = Radiobutton(window,
text="Small",
variable=size,
value="Small",
font=('Arial', 15))
mediumRadio = Radiobutton(window,
text="Medium",
variable=size,
value="Medium",
font=('Arial', 15))
largeRadio = Radiobutton(window,
text="Large",
variable=size,
value="Large",
font=('Arial', 15))
smallRadio.select()#SETS DEFAULT
smallRadio.grid(row=2, column=0, sticky=W)
mediumRadio.grid(row=2, column=1, sticky=W)
largeRadio.grid(row=2, column=2, sticky=W)
pepperoni = Checkbutton(window,
text="Pepperoni",
variable=pp,
onvalue =1,
offvalue=0,
padx=30,
font=('Arial', 14))
olives = Checkbutton(window,
text="Olives",
variable=ol,
onvalue =1,
offvalue=0,
padx=30,
font=('Arial', 14))
pineapple = Checkbutton(window,
text="Pineapple ",
variable=pin,
onvalue =1,
offvalue=0,
padx=30,
font=('Arial', 14))
sausage = Checkbutton(window,
text="Sausage",
variable=ss,
onvalue =1,
offvalue=0,
padx=30,
font=('Arial', 14))
onions = Checkbutton(window,
text="Onions",
variable=on,
onvalue =1,
offvalue=0,
padx=30,
font=('Arial', 14))
bellpepper = Checkbutton(window,
text="Bell Pepper",
variable=bp,
onvalue =1,
offvalue=0,
padx=30,
font=('Arial', 14))
def selection_changed(event):
selection = payment.get() # gets the selected item from combo
def resetFields():
userName.delete(0,END)
pepperoni.deselect()
olives.deselect()
pineapple.deselect()
sausage.deselect()
onions.deselect()
bellpepper.deselect()
largeRadio.select() #SETS DEFAULT Radiobutton
payment.set("Visa")
def writeToFile():
if not userName.get().strip():
messagebox.showerror("Error", "Customer name cannot be empty.")
return
log = open("order.txt", 'a')
log.write('Name: %s\n' % userName.get())
log.write(f'Size: {size.get()}\n')
log.write(f'Card: {payment.get()}\n')
from datetime import datetime
timestamp = datetime.now().strftime('%m/%d/%Y %I:%M %p')
log.write(f'Time: {timestamp}\n')
log.write("===================================================\n")
log.close()
clear = Button(window,
text='Clear',
command=resetFields,
font=('Arial', 16))
resetFields()
submit = Button(window,
text='Submit',
command=writeToFile,
font=('Arial', 16))
clear.grid(row=10, column=0, sticky=E)
submit.grid(row=10, column=2, sticky=W)
window.mainloop()