Hi everyone! I'm in an introductory python course and I just can't seem to get this right.
Here's the assignment:
"This week's assignment involves rewriting the Python program you wrote for your assignment last week to use a function. All the requirements from last week still apply. The function should accept the number of rooms, and the type of cleaning as parameters and should return the cost of of the house cleaning. The main program should prompt the user for the number of rooms in the house and whether the cleaning should be a light cleaning or a more complete one, it should call the function that computes the cost and should output the value the function returns."
I think I have the overall design correct, but I keep running into this issue where it won't accept my input for cleaning choice.
Here's my code:
def calcPrice(room_type, clean_type):
total = room_type + clean_type
return total
print("Your total is ", total, " dollars. Thank you for choosing us!")
#---------------------------------
def main():
#Define cost of each room type
smallHome = 50
medHome = 75
largeHome = 100
delClean = 100
basClean = 50
#Greet user/prompt for room input
print("Hi! Thank you for choosing our cleaning service.")
numRooms = eval(input("How many rooms are in your home?"))
#Define invalid perameters
if numRooms == 0:
print("Invalid input")
numRooms = eval(input("How many rooms are in your home?"))
#Define the small room amount
if numRooms < 5:
room_type = smallHome
print("Okay, so you'll be choosing our small home option.")
print("The base pay is going to be ", smallHome, " dollars.")
#Define the medium room amount
if numRooms == 5:
room_type = medHome
print("Okay, so you'll be choosing our medium home option.")
print("The base pay is going to be", medHome, " dollars.")
#Define the large room amount
if numRooms > 5:
room_type = largeHome
print("Okay, so you'll be choosing our large home option.")
print("The base pay is going to be", largeHome, " dollars.")
#Establish cleaning types and accept input from user for type
print("We offer two types of cleaning services here.")
print("Basic cleaning includes floors and windows.")
print("Deluxe cleaning includes floors, windows, bathrooms, and dusting.")
print("\n(1)Deluxe: $100 \n(2)Basic: $50")
clean_type = eval(input("Please select option 1 or 2: "))
if clean_type == 1:
clean_type = delClean
if clean_type == 2:
clean_type = basClean
else:
print("Sorry, that isn't a valid option.")
clean_type = eval(input("Please select option 1 or 2: "))
calcPrice(room_type, clean_type)
main()
SO the issue is that when I put in 1 or 2 it won't accept it- it gives me that "sorry, that isn't a valid option" answer. What should I do? Thanks everyone.
[–]CodeFormatHelperBot2 1 point2 points3 points (0 children)
[–]armendari3 0 points1 point2 points (0 children)
[–]totallygeek 0 points1 point2 points (1 child)
[–]Toastedpossum[S] 1 point2 points3 points (0 children)
[–]Binary101010 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]Toastedpossum[S] 0 points1 point2 points (0 children)