r/pythonhomeworkhelp • • Jun 19 '24

Text Based Game: Player cannot leave starting position

0 Upvotes
class Room:
    def __init__(self, name, description=""):
         = name
        self.description = description
        self.items = []
        self.exits = {}

    def add_exit(self, direction, room):
        self.exits[direction] = room
    def add_item(self, item):
        self.items.append(item)


class Item:
    def __init__(self, name, description=""):
         = name
        self.description = description
def setup_rooms():
    rooms = {
        'Bedroom': {'south': 'Kitchen', 'east': 'Bathroom'},
        'Kitchen': {'north': 'Bedroom', 'east': 'Living Room', 'south': 'Laundry Room', 'item': 'Sack of feathers'},
        'Bathroom': {'west': 'Bedroom', 'south': 'Living Room', 'item': 'Master Key'},
        'Closet': {'south': 'Master Bedroom', 'west': 'Bathroom'},
        'Living Room': {'north': 'Bathroom', 'east': 'Master Bedroom', 'west': 'Kitchen', 'item': 'Bucket'},
        'Laundry Room': {'north': 'Kitchen', 'east': 'Garage', 'item': 'Washing Machine'},
        'Master Bedroom': {'north': 'Closet', 'west': 'Living Room'},
        'Garage': {'west': 'Laundry Room', 'north': 'Living Room', 'item': 'Rope'},
    }

    room_objects = {}
    for room_name in rooms:
        room_objects[room_name] = Room(room_name, description=f"This is the {room_name}.")

    for room_name, details in rooms.items():
        current_room = room_objects[room_name]
        for direction, connected_room in details.items():
            if direction != 'item':
                current_room.add_exit(direction.lower(), room_objects[connected_room])
            else:
                item = Item(details['item'])
                current_room.add_item(item)

    return room_objects
def show_instructions():
    print("Revenge on Step Mom")
    print("Collect all the items to progress through the locked Master Bedroom")
    print("Move Commands: South, North, East, West")
    print("Add to Inventory: get 'item name'")


def show_status(current_room, inventory):
    print(f"You are in the {current_room.name}")
    print(f"Inventory: {inventory}")
    if current_room.items:
        for item in current_room.items:
            print(f"- {item.name}")
    print("-------------------")

def check_win_condition(current_room, inventory):
    if current_room.name == 'Master Bedroom' and 'Master Key' in inventory:
        print("Congratulations! You've unlocked the Master Bedroom!")
        print("You tie Sandra up, pour hot tar and feathers all over her! Her screams are like music to your ears.")
        print("You have earned that Capri Sun.")
        return True
    return False
def main():
    show_instructions()

    rooms = setup_rooms()
    current_room = rooms['Bedroom']
    inventory = []

    while True:
        show_status(current_room, inventory)

        command = input("Enter a command: ").lower().strip()
        if command in ['north', 'south', 'east', 'west']:
            if command in current_room.exits:
                current_room = current_room.exits[command]
            else:
                print("I can't go that way.")
        elif command.startswith("get "):
            item_name = command[4:].strip()
            item_found = False
            for item in current_room.items:
                if item.name.lower() == item_name:
                    inventory.append(item.name)
                    current_room.items.remove(item)
                    item_found = True
                    print(f"{item_name} added to inventory.")
                    break
            if not item_found:
                print(f"No {item_name} found here.")
        elif command == 'exit':
            print("Goodbye!")
            break
        else:
            print("Invalid direction")


if __name__ == "__main__":
    main()self.nameself.name

#Ouput
You are in the Bedroom
Enter a command (North, South, East, West, or exit): east
You can't go that way!
You are in the Bedroom
Enter a command (North, South, East, West, or exit): East

A simple text based game for a class. There may be other issues but I can't even leave the bedroom to continue to debug lol


r/pythonhomeworkhelp • • Oct 19 '22

Can someone help (code below picture)

1 Upvotes

This is the output I need

I keep getting assertion errors with this code:

from breezypythongui import EasyFrame
class TidbitGUI(EasyFrame):
def __init__(self):
        EasyFrame.__init__(self, title = "Tidbit Loan Scheduler")
self.addLabel(text="Purchase Price",row=0,column=0)

self.priceField = self.addFloatField(value=0.0,row=0, column=1)
self.addLabel(text="Annual Interest Rate",row=1,column=1)

self.rateField = self.addIntegerField(value=0,row=1,column=1)
self.button = self.addButton(text="Compute", row=2, column=0,columnspan=2,command=self.computeSchedule)
self.button.bind("<Return>", lambda event: self.computeSchedule())

self.outputArea = self.addTextArea("",row=3,column=0, columnspan=3,width=84,height=15)
def computeSchedule(self):

        annual_rate = self.rateField.getNumber() / 100
        monthly_rate = annual_rate / 12
        purchase_price = self.priceField.getNumber()
        mounthly_payment = 0.05 * (purchase_price - (0.10 * purchase_price))
        month = 1
        balence = purchase_price
self.outputArea.setText("Month  Starting Balance  Interest to Pay  Principal to Pay Payment  Ending Balance\n")
while balence > 0:
if mounthly_payment == balence:
                mounthly_payment = balence
                interest = 0
else:
                interest = balence * monthly_rate
                principle = mounthly_payment - interest
                remaining_balence = balence - mounthly_payment
                monthly_numbers = str("%2d%15.2f%15.2f%17.2f%17.2f%17.2f\n" % \
                (month, balence, interest, principle, mounthly_payment, remaining_balence))
self.outputArea.appendText(monthly_numbers)
                balence = remaining_balence
                month += 1
def main():

    TidbitGUI().mainloop()
if __name__ == "__main__":
try:
while True:
            main()
except KeyboardInterrupt:
print("\nProgram closed.")


r/pythonhomeworkhelp • • Aug 15 '23

Making Variables More Flexible – How to Have Users Enter Data.

Thumbnail
elevatepython.com
1 Upvotes

r/pythonhomeworkhelp • • Apr 10 '24

How do I calculate the Big O runtime for this given function

1 Upvotes

def mystery_v2(lst: list[str]) -> str:
answer = ’ ’
i = 0
done = False
while not done:
next_list = []
done = True
for s in lst:
if i < len(s):
answer += s[i]
done = False
next_list.append(s)
i += 1
lst = next_list
return answer

Scenario: A list with n strings (n > 0), all of length 5, except for one string of length m (m > 5).
For this scenario, what is the Big-Oh runtime of v2 in terms of n and m?


r/pythonhomeworkhelp • • Nov 03 '24

mad libs help needed

1 Upvotes

I am super new to python so my code is an absolute mess. I'm trying to create a program that has 2 stories in it that a user can choose from. Then collects the words to input into the stories. Then it loops back and let's them do another if they'd like and it counts the number of stories they've created.

My link to the trinket I've made so far: https://trinket.io/python3/ba5c267d4262

My issues currently:

this endless loop - I think it's caused by what I've got in def main():

redirecting the user to inputting a correct answer if they put something other than y/n for the do you want to play the game portion

redirect the user to inputting a correct answer if they put something other than A or B for which story they want to do

having a properly function tracker for the story count


r/pythonhomeworkhelp • • Mar 04 '23

I need help adding a try/except to my code

1 Upvotes

I am trying to write a code that meets these guidelines:

"Write a function that takes two lists as its parameters and checks if they have the same length. If this is not the case the function should raise a ValueError. If they have the same length the function should create a dictionary, using the first list for keys and the second list for values. The creation of the dictionary should happen in a try except statement, for the case the first list contains mutable types (which should not be used for keys). Finally, the function should return the dictionary."

I wrote this code:

list1 = [1,2,3]
list2 = ["a","b","c", "d"]
list3 = ["x", "y", "z"]
def exer4(a,b):
        if len(a) == len(b):
            dictionary = dict(zip(a,b))
            print(dictionary)
        else:
            print("nah")
exer4(a= list1, b = list2)
exer4(a= list1, b = list3)

But as per the question, I need to make this happen using try/except. When I try to add try somewhere in the problem, calling the function gives me an indent error.

Thank you!


r/pythonhomeworkhelp • • Feb 23 '23

Object-Oriented Habit App Homework

1 Upvotes

Hello everyone,

Based on the following two files, can someone point me in the direction of fixing the error at the bottom of this post.

Interface: 

from habit import HabitDB, Habit from questionary import prompt, select, text

def create_habit():
    name = text("What is the name of the habit?").ask()
    frequency = select("What is the frequency of the habit?", choices=["daily", "weekly", "monthly"]).ask()
    habit = HabitDB(name, frequency)
    habit.save_habit()

def mark_habit_complete():
    habits = HabitDB.get_all_habits()
    habit_names = [habit.name for habit in habits]
    habit_name = select("Which habit do you want to mark as complete?", choices=habit_names).ask()
    habit = next(filter(lambda h: h.name == habit_name, habits))
    habit.mark_complete()
    habit.update()

def delete_habit():
    habits = HabitDB.get_all_habits()
    habit_names = [habit.name for habit in habits]
    habit_name = select("Which habit do you want to delete?", choices=habit_names).ask()
    habit = next(filter(lambda h: h.name == habit_name, habits))
    habit.delete()

def list_habits():
    frequency = select("Which frequency do you want to list habits for?", choices=["daily", "weekly", "monthly"]).ask()
    habits = HabitDB.list_by_frequency(frequency)
    if not habits:
        print(f"No habits found with frequency '{frequency}'")
    else:
        print(f"Habits with frequency '{frequency}':")
        for habit in habits:
            print(habit)

def get_streak():
    habits = HabitDB.get_all_habits()
    habit_names = [habit.name for habit in habits]
    habit_name = select("Which habit do you want to get the streak for?", choices=habit_names).ask()
    habit = next(filter(lambda h: h.name == habit_name, habits))
    streak = habit.get_streak()
    print(f"The streak for habit '{habit_name}' is {streak} days")
    
def help():
    print("Commands:")
    print("create_habit - create a habit")
    print("mark_habit_complete - mark a habit as complete")
    print("delete_habit - delete a habit")
    print("list_habits - list all habits")
    print("get_streak - get the streak for a habit")
    print("exit - exit the program")

if __name__ == "__main__":
    help()
    while True:
        command = select("What would you like to do?", choices=["create_habit", "mark_habit_complete", "delete_habit", "list_habits", "get_streak", "exit"]).ask()
        if command == "create_habit":
            create_habit()
        elif command == "mark_habit_complete":
            mark_habit_complete()
        elif command == "delete_habit":
            delete_habit()
        elif command == "list_habits":
            list_habits()
        elif command == "get_streak":
            get_streak()
        elif command == "exit":
            break
        else:
            print("Invalid command")

Habit Class:

import sqlite3
from datetime import datetime, timedelta

class Habit:
    def __init__(self, name="", frequency="", completed=[]):
        self.name = name
        self.frequency = frequency
        self.completed = []
    
    def mark_complete(self):
        today = datetime.today().date()
        self.completed.append(today)
    
    def is_complete(self):
        if self.frequency == 'daily':
            return datetime.today().date() in self.completed
        elif self.frequency == 'weekly':
            start_of_week = (datetime.today().date() - timedelta(days=datetime.today().date().weekday()))
            end_of_week = start_of_week + timedelta(days=6)
            for day in range((end_of_week - start_of_week).days + 1):
                date = start_of_week + timedelta(days=day)
                if date in self.completed:
                    return True
            return False
        elif self.frequency == 'monthly':
            today = datetime.today().date()
            if today.day >= 28:
                end_of_month = today.replace(day=28) + timedelta(days=4)
                for day in range((end_of_month - today).days + 1):
                    date = today + timedelta(days=day)
                    if date in self.completed:
                        return True
                return False
            else:
                return today.replace(day=1) in self.completed
    
    def get_streak(self):
        streak = 0
        today = datetime.today().date()
        for day in range((today - timedelta(days=30)).days, (today - timedelta(days=1)).days + 1):
            date = today - timedelta(days=day)
            if date in self.completed:
                streak += 1
            else:
                break
        return streak

class HabitDB:
    def __init__(self, name="", frequency="", completed=[]):
        self.conn = sqlite3.connect('habits.db')
        self.cursor = self.conn.cursor()
        self.create_table()
    
    def create_table(self):
        self.cursor.execute('''CREATE TABLE IF NOT EXISTS habits
                          (name TEXT PRIMARY KEY, frequency TEXT, completed TEXT)''')
    
    def save_habit(self, habit):
        self.cursor.execute('INSERT INTO habits (name, frequency, completed) VALUES (?, ?, ?)', (habit.name, habit.frequency, str(habit.completed)))
        self.conn.commit()
        
    
    def update_habit(self, habit):
        self.cursor.execute('UPDATE habits SET completed = ? WHERE name = ?', (str(habit.completed), habit.name))
        self.conn.commit()
    
    def delete_habit(self, habit):
        self.cursor.execute('DELETE FROM habits WHERE name = ?', (habit.name,))
        self.conn.commit()
    
    def list_habits_by_frequency(self, frequency):
        self.cursor.execute('SELECT name FROM habits WHERE frequency = ?', (frequency,))
        rows = self.cursor.fetchall()
        return [row[0] for row in rows]
    
    def get_all_habits(self):
        self.cursor.execute('SELECT * FROM habits')
        rows = self.cursor.fetchall()
        return rows

Traceback:

Traceback (most recent call last):
  File "/home/brandon/IU International University/Object-Oriented and Functional Programing with Python/Habit Tracker v3/main.py", line 57, in <module>
    create_habit()
  File "/home/brandon/IU International University/Object-Oriented and Functional Programing with Python/Habit Tracker v3/main.py", line 8, in create_habit
    habit.save_habit()
TypeError: save_habit() missing 1 required positional argument: 'habit'

It states that I am missing a positional argument, however it should have been created when entering all the necessary information into the interface prompts. Any assistance will be greatly appreciated. Thanks in advance!


r/pythonhomeworkhelp • • Sep 23 '22

Python hw help!

Thumbnail
gallery
1 Upvotes

r/pythonhomeworkhelp • • Nov 14 '23

ZZZ Code AI | Support this website

2 Upvotes

r/pythonhomeworkhelp • • Jun 22 '23

Python water bill calculator assignemnt

2 Upvotes

Hey guys I am working on my Computer science project and I am stuck. Here is my code, how do I fix the errors listed on the bottom
import tkinter as tk
from tkinter import messagebox
# Create the main window
window = tk.Tk()
window.title("Water Bill Calculator")
# Customer Information Box
customer_info_frame = tk.LabelFrame(window, text="Customer Information")
customer_info_frame.grid(row=0, column=0, padx=10, pady=10, sticky="w")
# Labels and Entry Fields for Customer Information
labels = ["Name:", "Address:", "City:", "Province:", "ZIP Code:"]
entries = []
for i, label_text in enumerate(labels):
label = tk.Label(customer_info_frame, text=label_text)
label.grid(row=i, column=0, sticky="e")
entry = tk.Entry(customer_info_frame, width=30)
entry.grid(row=i, column=1, padx=5)
entries.append(entry)
entries[2].insert(0, "Midland") # Prefill City field with "Midland"
entries[3].insert(0, "Ontario") # Prefill Province field with "Ontario"
entries[4].insert(0, "L4R") # Prefill ZIP Code field with "L4R"
# Water Usage Box
water_usage_frame = tk.LabelFrame(window, text="Water Usage")
water_usage_frame.grid(row=0, column=1, padx=10, pady=10, sticky="w")
# Labels and Entry Fields for Water Usage
water_usage_labels = ["Last Meter Read:", "Current Meter Read:", "Litres Used:"]
water_usage_entries = []
for i, label_text in enumerate(water_usage_labels):
label = tk.Label(water_usage_frame, text=label_text)
label.grid(row=i, column=0, sticky="e")
entry = tk.Entry(water_usage_frame, width=10)
entry.grid(row=i, column=1, padx=5)
water_usage_entries.append(entry)
# Sewer Usage Box
sewer_usage_frame = tk.LabelFrame(window, text="Sewer Usage")
sewer_usage_frame.grid(row=0, column=2, padx=10, pady=10, sticky="w")
# Labels and Entry Fields for Sewer Usage
sewer_usage_labels = ["Litres Used:", "Discount Amount:", "Billable Amount:"]
sewer_usage_entries = []
for i, label_text in enumerate(sewer_usage_labels):
label = tk.Label(sewer_usage_frame, text=label_text)
label.grid(row=i, column=0, sticky="e")
entry = tk.Entry(sewer_usage_frame, width=10, state="readonly")
entry.grid(row=i, column=1, padx=5)
sewer_usage_entries.append(entry)
# Bill Summary Box
bill_summary_frame = tk.LabelFrame(window, text="Water Charges")
bill_summary_frame.grid(row=1, column=1, padx=10, pady=10, sticky="w")
# Labels and Entry Fields for Bill Summary
bill_summary_labels = ["Water Usage:", "Water Rate:", "Service Charge:", "Total:"]
bill_summary_entries = []
for i, label_text in enumerate(bill_summary_labels):
label = tk.Label(bill_summary_frame, text=label_text)
label.grid(row=i, column=0, sticky="e")
entry = tk.Entry(bill_summary_frame, width=10, state="readonly")
entry.grid(row=i, column=1, padx=5)
bill_summary_entries.append(entry)
# Sewer Charges Box
sewer_charges_frame = tk.LabelFrame(window, text="Sewer Charges")
sewer_charges_frame.grid(row=1, column=2, padx=10, pady=10, sticky="w")
# Labels and Entry Fields for Sewer Charges
sewer_charges_labels = ["Sewer Usage:", "Sewer Rate:", "Service Charge:", "Total:"]
sewer_charges_entries = []
for i, label_text in enumerate(sewer_charges_labels):
label = tk.Label(sewer_charges_frame, text=label_text)
label.grid(row=i, column=0, sticky="e")
entry = tk.Entry(sewer_charges_frame, width=10, state="readonly")
entry.grid(row=i, column=1, padx=5)
sewer_charges_entries.append(entry)
# Grand Total
grand_total_label = tk.Label(window, text="Grand Total:")
grand_total_label.grid(row=2, column=1, padx=10, pady=10, sticky="e")
grand_total_entry = tk.Entry(window, width=10, state="readonly")
grand_total_entry.grid(row=2, column=2, padx=5)
# Service Type
service_var = tk.StringVar(value=None) # Set initial value to None
service_type_frame = tk.LabelFrame(window, text="Service Type")
service_type_frame.grid(row=1, column=0, padx=10, pady=10, sticky="w")
water_only_radio = tk.Radiobutton(service_type_frame, text="Water only", variable=service_var, value="water")
water_only_radio.grid(row=0, column=0, padx=5, pady=2)
water_sewage_radio = tk.Radiobutton(service_type_frame, text="Water and Sewage", variable=service_var, value="water_sewer")
water_sewage_radio.grid(row=1, column=0, padx=5, pady=2)
def clear_service_type():
service_var.set("")
# Exit Button
def exit_program():
window.destroy()
exit_button = tk.Button(window, text="Exit", command=exit_program)
exit_button.grid(row=3, column=2, padx=5, pady=10, sticky="e")
# Reset Form Button
def reset_form():
clear_service_type()
for entry in entries:
entry.delete(0, tk.END)
entries[2].insert(0, "Midland") # Prefill City field with "Midland"
entries[3].insert(0, "Ontario") # Prefill Province field with "Ontario"
entries[4].insert(0, "L4R") # Prefill ZIP Code field with "L4R"
for water_entry in water_usage_entries:
water_entry.delete(0, tk.END)
for sewer_entry in sewer_usage_entries:
sewer_entry.delete(0, tk.END)
for bill_entry in bill_summary_entries:
bill_entry.delete(0, tk.END)
for water_charges_entry in water_charges_entries:
water_charges_entry.delete(0, tk.END)
for sewer_charges_entry in sewer_charges_entries:
sewer_charges_entry.delete(0, tk.END)
grand_total_entry.configure(state="normal")
grand_total_entry.delete(0, tk.END)
grand_total_entry.configure(state="readonly")
reset_button = tk.Button(window, text="Reset Form", command=reset_form)
reset_button.grid(row=3, column=1, pady=5)
# Calculate Button
def calculate_bill():
# Check if all required fields are filled
for entry in entries:
if entry.get().strip() == "":
messagebox.showerror("Error", "Please fill in all customer information fields.")
entry.focus()
return
if water_usage_entries[0].get().strip() == "" or water_usage_entries[1].get().strip() == "":
messagebox.showerror("Error", "Please enter both last meter read and current meter read.")
water_usage_entries[0].focus()
return
# Check if current meter reading is greater than previous meter reading
last_meter_read = int(water_usage_entries[0].get())
current_meter_read = int(water_usage_entries[1].get())
if current_meter_read <= last_meter_read:
messagebox.showerror("Error", "Current meter reading must be greater than previous meter reading.")
water_usage_entries[0].delete(0, tk.END)
water_usage_entries[1].delete(0, tk.END)
water_usage_entries[0].focus()
return
# Calculate Litres Used
litres_used = current_meter_read - last_meter_read
if service_var.get() == "Water only":
# Calculate Water charges
water_usage_entries[2].configure(state="normal")
water_usage_entries[2].delete(0, tk.END)
water_usage_entries[2].insert(0, litres_used)
water_usage_entries[2].configure(state="readonly")
if litres_used <= 10000:
water_rate = 3.50
elif litres_used <= 20000:
water_rate = 3.25
elif litres_used <= 50000:
water_rate = 3.05
else:
water_rate = 2.90
if litres_used <= 50000:
water_service_charge = 7.50
else:
water_service_charge = 6.50
water_total = (litres_used / 1000) * water_rate + water_service_charge
# Calculate Sewer charges
sewer_usage_entries[0].configure(state="normal")
sewer_usage_entries[0].delete(0, tk.END)
sewer_usage_entries[0].insert(0, 0)
sewer_usage_entries[0].configure(state="readonly")
sewer_rate = 0
sewer_service_charge = 0
sewer_total = 0
else:
# Calculate Water charges
water_usage_entries[2].configure(state="normal")
water_usage_entries[2].delete(0, tk.END)
water_usage_entries[2].insert(0, litres_used)
water_usage_entries[2].configure(state="readonly")
if litres_used <= 10000:
water_rate = 3.50
elif litres_used <= 20000:
water_rate = 3.25
elif litres_used <= 50000:
water_rate = 3.05
else:
water_rate = 2.90
if litres_used <= 50000:
water_service_charge = 6.50
else:
water_service_charge = 5.50
water_total = (litres_used / 1000) * water_rate + water_service_charge
# Calculate Sewer charges
sewer_usage_entries[0].configure(state="normal")
sewer_usage_entries[0].delete(0, tk.END)
sewer_usage_entries[0].insert(0, litres_used)
sewer_usage_entries[0].configure(state="readonly")
discount_amount = litres_used * 0.025
billable_amount = litres_used - discount_amount
sewer_usage_entries[1].configure(state="normal")
sewer_usage_entries[1].delete(0, tk.END)
sewer_usage_entries[1].insert(0, discount_amount)
sewer_usage_entries[1].configure(state="readonly")
sewer_usage_entries[2].configure(state="normal")
sewer_usage_entries[2].delete(0, tk.END)
sewer_usage_entries[2].insert(0, billable_amount)
sewer_usage_entries[2].configure(state="readonly")
if billable_amount <= 50000:
sewer_rate = 1.25
sewer_service_charge = 12.50
else:
sewer_rate = 1.15
sewer_service_charge = 10.50
sewer_total = (billable_amount / 1000) * sewer_rate + sewer_service_charge
# Update Bill Summary
bill_summary_entries[0].configure(state="normal")
bill_summary_entries[0].delete(0, tk.END)
bill_summary_entries[0].insert(0, litres_used)
bill_summary_entries[0].configure(state="readonly")
bill_summary_entries[1].configure(state="normal")
bill_summary_entries[1].delete(0, tk.END)
bill_summary_entries[1].insert(0, water_rate)
bill_summary_entries[1].configure(state="readonly")
bill_summary_entries[2].configure(state="normal")
bill_summary_entries[2].delete(0, tk.END)
bill_summary_entries[2].insert(0, water_service_charge)
bill_summary_entries[2].configure(state="readonly")
water_total = round(water_total, 2)
bill_summary_entries[3].configure(state="normal")
bill_summary_entries[3].delete(0, tk.END)
bill_summary_entries[3].insert(0, water_total)
bill_summary_entries[3].configure(state="readonly")
# Update Sewer Charges
sewer_charges_entries[0].configure(state="normal")
sewer_charges_entries[0].delete(0, tk.END)
sewer_charges_entries[0].insert(0, billable_amount)
sewer_charges_entries[0].configure(state="readonly")
sewer_charges_entries[1].configure(state="normal")
sewer_charges_entries[1].delete(0, tk.END)
sewer_charges_entries[1].insert(0, sewer_rate)
sewer_charges_entries[1].configure(state="readonly")
sewer_charges_entries[2].configure(state="normal")
sewer_charges_entries[2].delete(0, tk.END)
sewer_charges_entries[2].insert(0, sewer_service_charge)
sewer_charges_entries[2].configure(state="readonly")
sewer_total = round(sewer_total, 2)
sewer_charges_entries[3].configure(state="normal")
sewer_charges_entries[3].delete(0, tk.END)
sewer_charges_entries[3].insert(0, sewer_total)
sewer_charges_entries[3].configure(state="readonly")
# Calculate Grand Total
grand_total = water_total + sewer_total
grand_total_entry.configure(state="normal")
grand_total_entry.delete(0, tk.END)
grand_total_entry.insert(0, grand_total)
grand_total_entry.configure(state="readonly")
# Calculate Button
calculate_button = tk.Button(window, text="Calculate Bill", command=calculate_bill)
calculate_button.grid(row=3, column=0, padx=5, pady=10)
# Start the main loop
window.mainloop()
There is errors like when the program starts the service type buttons are both selected for some reason and also the line in water usage called litres used for some reason allows the user to input information but when calculate bill button is pressed it does what it is supposed to do which is subtract the current meter reading from the previous meter reading, so that input field should be unavailable for the user to put anything in there. Also the reset button does not work as it should. When reset is pressed it only clears the customer information box and the meter readings not clearing out any of the rest of the lines and does not clear the service type buttons. Please help


r/pythonhomeworkhelp • • May 20 '24

Got CS Summer Classes? Get Help from Experienced CS tutors!

Post image
1 Upvotes

r/pythonhomeworkhelp • • Jul 14 '22

Is anyone able to help with this problem? TIA :)

Thumbnail
gallery
1 Upvotes

r/pythonhomeworkhelp • • Feb 20 '23

python help! Pretty simple I believe I am just stupid

1 Upvotes

Given  the following code, what is printed?

def mod_test(value, mod):
return value % mod

print(mod_test(26, 4))


r/pythonhomeworkhelp • • Aug 14 '23

The Ultimate 9 Commands And Concepts in Python.

Thumbnail
elevatepython.com
1 Upvotes

r/pythonhomeworkhelp • • Feb 24 '24

bowling game trouble

1 Upvotes

my cs class is making a bowling game with pyside6 and the logic for scoring is really getting me…

it’s a classic ten frame bowling game, i created all the frames with a loop so i wasn’t sure how to access individual frames. i am having an issue with the strike and spare logic because i don’t know how to access the next throw and add that to the last turns score…

any advice welcome ! (i have the files for anyone who might need to see)


r/pythonhomeworkhelp • • Jul 28 '23

The Ultimate Guide to Python Libraries

Thumbnail
elevatepython.com
1 Upvotes

r/pythonhomeworkhelp • • Jan 02 '24

How to make a contour plot of 3D points given as a CSV file

1 Upvotes

My professor gave us a CSV file full of 3D points and told us to create a contour plot. Whenever I try to to create a plot, spyder says that my z array needs to be 2D. Does anyone have any advice on how to make this work?


r/pythonhomeworkhelp • • Aug 12 '23

The ultimate guide to “Nested” Lists.

Thumbnail
elevatepython.com
1 Upvotes

r/pythonhomeworkhelp • • Aug 09 '23

Simple Guide To Lists - Python.

Thumbnail
elevatepython.com
1 Upvotes

r/pythonhomeworkhelp • • Aug 12 '23

The ultimate guide to “Nested” Lists.

Thumbnail
elevatepython.com
1 Upvotes

r/pythonhomeworkhelp • • Dec 07 '23

Psychopy homework

2 Upvotes

Does anyone know psychopy??


r/pythonhomeworkhelp • • Aug 03 '23

Python Commands: Learning the Basics Made Easy.

Thumbnail
elevatepython.com
1 Upvotes

r/pythonhomeworkhelp • • Jul 22 '23

An Ultimate Guide to IF Statements - Python

Thumbnail
elevatepython.com
1 Upvotes

r/pythonhomeworkhelp • • Feb 08 '25

[beginner] Probably a dumb question but I'm stuck!!

Post image
1 Upvotes

Qn : FIND ONE TEST CASE THAT SATISFIES THE REQUIREMENTS OF INPUT (n>= 2), BUT THE CODE GIVES INCORRECT RESULT.

Preamble given: A prime number is a positive integer greater than 1, divisible only by 1 and itself. To check if a number p is prime, we only need to test divisibility up to the square root of p. The input n will always be a positive integer greater than or equal to 2.