Description
INTRODUCTION
In this assignment, you will get practice with:
Basic Python programming constructs
Expressions, decisions
Getting input from users
Algorithm development and testing; designing test cases
Following program specifications
loops
As you organize a dinner assembly for your closest friends at a restaurant in your city, you find yourself searching
for the perfect place to dine.
After much contemplation, you decide to take your companions to a restaurant that
accommodates the dietary restrictions of your friends. Therefore, you decided to write a Python program inquiring
about any Keto, vegan, or gluten-free dietary needs among your party members and subsequently listing the
suitable meals for dinner. Table I shows the available meals according to the dietary restrictions accommodated in
this restaurant.
If the invitee has a different dietary preference that does not match any of the meals in the menu above, a
beverage is offered for $5.99
ASSIGNMENT WAKTHROU!
To make it easier for you, please have a look at the video below. The video walks through the important parts
of the assignment. In addition to some extra tests that shows the input/output.
TOP
1 FILES
For this assignment, you are asked to submit one file named dinner.py containing all the code required to
complete this assignment.
Your program should run according to the following specifications:
0:00 / 17:45
The program will ask the user to specify the number of invitees by showing the message
“Please enter the number of invitees:”
The user is expected to enter a positive integer representing the number of invitees. We assume that the
user will always provide valid input.
1
According to the number of invitees, your program should loop over all the invitees to gather information
about each individual’s dietary preferences. This is accomplished as follows:
Show the user the invitee number that you are taking the information about. You should show the
message
“Please enter the order details for invitee Number X/Y”
where X is the invitee number and Y is the number of invitees.
The program will then ask the user if the invitee has a Keto diet with the message
“Do you want a keto friendly meal?”
If the user answers (y lowercase) that means yes. Anything else, even the word “yes” should be
considered no.
The program will then ask the user if the invitee prefers a vegan meal with the message
“Do you want a vegan meal?”
If the user answers (y as lowercase) that means yes. Otherwise, it is considered no.
The program will then ask the user if the invitee prefers a Gluten-free meal with the message
2
TOP
“Do you want a Gluten-free meal?”
If the user answers (y lowercase) that means yes. Otherwise, it is considered no.
Your program should decide what is the appropriate meal from the menu according to the collected
dietary preference for each invitee. e.g., if the user enteres y then y then y, your program should
serve Falafel for this particular friend. If the user enterss no then n then y, the program should
serve beverage for this friend as none of the meals in the menu satisfies this preference.
The program should keep asking the user these questions until all invitees’ preferences are collected.
When all the information is gathered, your program will ask the user to tip the server by entering a positive
number representing the percentage of the total bill to be given as a tip. The program will show
“How much do you want to tip your server (% percent)?”
And the user is assumed to enter a positive integer for the tip. E.g., if the user entered 15, this means that
the tip is 15% of the total cost after tax.
3
The program then will display the order details as the following 5 lines:
Your program prints
“You have X invitees with the following orders:”
where X is the number of invitees.
Your program then prints
“Y invitees ordered Pizza. The cost is: $N”
where Y is the number of invitees who ordered pizza and N is the total cost for only those people,
rounded to two decimal points.
Your program then prints
“Y invitees ordered Pasta. The cost is: $N”
where Y is the number of invitees who ordered Pasta and N is the total cost for only those people,
rounded to two decimal points.
Your program then prints
“Y invitees ordered Falafel. The cost is: $N”
where Y is the number of invitees who ordered Falafel and N is the total cost for only those people,
rounded to two decimal points.
Your program then prints
“Y invitees ordered Steak. The cost is: $N”
where Y is the number of invitees who ordered Steak and N is the total cost for only those people,
rounded to two decimal points.
Your program then prints
“Y invitees ordered only beverage. The cost is: $N”
where Y is the number of invitees who ordered beverage and N is total cost for only those people,
rounded to two decimal points.
4
The program then will display the total cost of the bill in three lines as follows:
Your program prints
“The total cost before tax is $H ”
where H is the total cost to all orders before any tax. H is printed to the nearest two decimal places.
5
TOP
Functional Specifications
Your program will execute as described above. The following are a few examples of the inputs and the expected
outputs:
Case 1:
Case 2:
Case 3:
Your program then prints
“The total cost after tax is $N ”
where N is the total cost to all orders after tax which is 13% of the total cost. You should use the total
cost calculated in the previous step, H, to print N. And, N is printed to the nearest two decimal places.
Your program then prints
“The total cost after X% tip is $Y”
where X is the tip percentage, and Y is the total cost to all orders after the tip. You should use the total
cost calculated in the previous step, N, to print Y. And, Y is rounded to the nearest integer. You can use
the following equation to calculate Y:
Non-Functional Specifications
The program should strictly adhere to the input and output requirements, particularly the order of the input
and the labelling of the output cost.
The program should include brief comments in your code identifying yourself, describing the program, and
describing key portions of the code.
You should be bothered with writing meaningful code comments to help others, including the grading team,
understand your code. A code comment that describes:
Identifying yourself
Describe the program and the reasoning behind it
Its input(s) and output(s)
Describing key portions of the code
An example of a good comment practice:
Assignments must be done individually and must be your work. Software may be used to detect academic
dishonesty (cheating).
Use Python coding conventions and sound programming techniques. For example:
Meaningful variable names
Conventions for naming variables and constants
Use of constants where appropriate
Readability, indentation, and consistency
2 TIPS AND GUIDELINES
Variables should be named in lowercase for single words and camel case for multiple words, e.g.,
noOfInviteesOrderedPizza
You can assume that all values entered are valid. You do not need to check if the input is valid
Make sure to use the exact wording and spacing of the messages prompted to the user. You can copy/paste it
for your convenience.
Include all the puncuations as demonstrated in the examples. This is bacause marking will be very sensitive to
formatting.
Testing Your Program
Wondering how to verify the effectiveness of your solution? Developing a set of test cases can assist in checking
the thoroughness and precision of your code. While the abovementioned examples are not exhaustive, they will aid
in this pursuit.
However, please note that the success of these test cases does not guarantee the complete
correctness and completeness of your code. It is important to consider additional test cases that will further
confirm the completeness and accuracy of your provided solution. You can create an excel sheet to calculate and
compare what you get in the sheet with the output of your code.
3 RULES
Read and follow the instructions carefully.
Only submit the Python file described in the Files section of this document.
Submit the assignment on time. Late submissions will receive a late penalty of 10% per day.
Forgetting to submit a finished assignment is not a valid excuse for submitting late.
Submissions must be done on Gradescope. They will not be accepted by email.
You may re-submit your code as many times as you would like. Gradescope uses your last submission as the
one for grading by default. There are no penalties for re-submitting. However, re-submissions that come in
after the due date will be considered late and subject to penalties.
REMEMBER!
Make sure you develop your code with Python 3.9 or higher as the interpreter. Failure to do so may result in
the testing program failing.
Assignments will be run through a similarity checking software to check for code that looks very similar to
that of other students. Sharing or copying code in any way is considered plagiarism and may result in a mark
of zero (0) on the assignment and/or reported to the Dean’s Office. Plagiarism is a serious offence. Work is to
be done individually.
4 MARKING GUIDELINES
The assignment may be marked as a combination of your auto-graded tests and manual grading of your code logic,
comments, formatting, style, etc. Below is a breakdown of the marks for this assignment:
[50 marks] Testing your code for correctness and adherence to the specifications by producing the expected
output
[20 marks] Code logic and completeness
[10 marks] Comments
[10 marks] Code formatting
[10 marks] Meaningful and properly formatted variables
Total: 100 marks
– GRADESCOPE SUBMISSION
REMEMBER!
The weight of this assignment is 5% of the course mark.
You must submit the 1 files to the Assignment 1 submission page on Gradescope. The required file is
dinner.py .
1
The submission will be using Gradescope.
You can find the instruction on how to complete your submission by following the steps in this video:
2
REMEMBER!
Assignment submission after 11:55 PM will cause late penalty of 10% per day to be deducted from your
mark.
Submissions through the email will not be accepted at any circumstances.
Please check back this page whenever an announcement is posted regarding this assignment.
TOP