Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Sajad Ghulam
Courses Plus Student 34 PointsNeed help because my prof didn't really explain to me what to do.
All freshmen of ABC College must live on campus. Single room is $3000 per semester, while double room is $2000 per semester. There are also two meal plans to choose. The 21-meal plan serves 21 meals each week with the price of $3500 per semester. The 15 mean plan serves 15 meals each week with the price of $2800 per semester. Write a program for a freshman to choose room type and meal plan. Define and use the following two functions: choose_room: Display room types and get user choice. Display user choice. choose_meal: Display meal plans and get user choice. Display user choice. Each of these functions returns the price of the chosen item. You are allowed to write only one return statement in each function. Set the price of the room or meal plan and then return the price. Write a main function to implement the mainline logic of the program. Calculate and display the total price in the main function.
This part I got easily but the next part is what is confusing me: Rewrite your program in Problem 1. This time in the functions choose_room and choose_meal, you must have two return statements in each function. Instead of setting the price for each choice, just return the price.
Can anyone give me a example of what she is asking for?
1 Answer
Chris Freeman
Treehouse Moderator 68,468 PointsIt's best to ask the professor, but my take would be that problem one has a solution of:
if condition1:
price = x
else:
price = y
return price
Then problem 2 would be structured like:
if condition1:
return x
else:
return y