1. Homepage
  2. Programming
  3. CSSE1001/CSSE7030 Introduction to Software Engineering - Assignment 1 - Recipes and Ingredients: Shopamania COOK1001

CSSE1001/CSSE7030 Introduction to Software Engineering - Assignment 1 - Recipes and Ingredients: Shopamania COOK1001

Engage in a Conversation
PythonCSSE1001CSSE7030Introduction to Software EngineeringAustraliaThe University of Queensland

Recipes and Ingredients: Shopamania

COOK1001 Assignment 1 Semester 1, 2023 CSSE1001/CSSE7030 CourseNana.COM

1 Introduction

You are a single parent with four hungry children and the weekly grocery shop is becoming difficult. Luckily, you know a bit of Python and can write a program that generates a shopping list based on what recipes are going to be prepared that week. CourseNana.COM

2 Getting Started

Download a1.zip from Blackboard — this archive contains the necessary files to start this assignment. Once extracted, the a1.zip archive will provide the following files: a1.py This is the only file you will submit and is where you write your code. Do not make changes to any other files. constants.py Do not modify or submit this file, this file also contains some constants that will be useful in your implementation. In addition to these, you are encouraged to create your own constants in a1.py where possible. This is where you will find some recipes that can be added to the recipe book as well. CourseNana.COM

Note: You are not permitted to add any import statements to a1.py. Doing so will result in a deduction of up to 100% of your mark. CourseNana.COM

3 Terminology

In the context of this assignment: CourseNana.COM

recipe name: str represents the name of a recipe. Note: Recipe names should only contain lowercase letters from the English alphabet without any numbers or special characters. recipe: tuple[str, str] is a tuple containing two str’s. The first str in the tuple represents the name of the recipe. The second str contains all the ingredients in the form of 'amount measure ingredient_name', e.g. '115 g Nuttelex' which represents 115 grams of Nuttelex. When multiple ingredients are present, they are separated by a single comma. Note that there is no space. e.g. '115 g Nuttelex,50 g sugar' have a look at constants.py for examples. recipes: list[tuple[str, str]] is a list of recipes. Each recipe follows the format described above. Duplicates can exist. ingredient detail: tuple[float, str, str] , is a tuple containing information of a single ingredient. (amount, measure, ingredient name), e.g. (115.0, 'g', 'Nuttelex'). cookbook is a collection of all available recipes and you may use whatever type you feel is appropriate for it. Duplicates do not exist in the cookbook. CourseNana.COM

4 Interaction

This section provides an overview of the interaction. Where prompts and outputs are not explicitly mentioned in this section, please see Section 5. CourseNana.COM

4.1 Interaction loop

At the beginning of the interaction, the user is prompted with the message Please enter a command: (note the trailing space) to choose a command. Once a command is entered the user should be prompted again. The valid commands are outlined in Table 1. CourseNana.COM

Throughout the interaction, the user may add to or remove from the cookbook. They can also add to or remove from the list of recipes as well. You may assume that your program will not be tested for invalid inputs that do not match the expected commands in Table 1. The prompt should repeat until the user quit by entering the "Q" or "q" action. CourseNana.COM

Input Description
"H" or "h" Display a help message.
"Q" or "q" Quit.
"add {recipe}" adds a recipe to the list of recipes.
"rm {recipe}" removes a recipe from the collection.
"rm {ingredient name} {amount}" removes an ingredient from the shopping list.
"g" or "G" generates a shopping list based on the list of recipes.
"ls" list all recipes in shopping cart.
"ls -a" list all available recipes.
"ls -s" display shopping list.
"mkrec" creates a recipe.

Table 1: Potential command that user can choose. {recipe} denotes that the name of recipe should be provided. Values not surrounded by braces should be taken as string literals. CourseNana.COM

5 Implementation

This section outlines functions you are required to implement in your solution (in a1.py only). You are awarded marks for the number of tests passed by your functions when they are tested independently. Thus an incomplete assignment with some working functions may well be awarded more marks than a complete assignment with faulty functions. Your program must operate exactly as specified. In particular, your program’s output must match exactly with the expected output. Your program will be marked automatically so minor differences in output (such as whitespace or casing) will cause tests to fail resulting in a zero mark for that test. Each function is accompanied with some examples for usage to help you start your own testing. You should also test your functions with other values to ensure they operate according to the descriptions. CourseNana.COM

5.1 Required Functions

The following functions must be implemented in a1.py. They have been listed in order of increasing difficulty. It is highly recommended that you do not begin work on a later function until each of the preceding functions can at least behave as per the shown examples. You may implement additional functions if you think they will help with your logic or make your code easier to understand. Your first task should be writing function headers for each of these required functions into a1.py. For example, you could write CourseNana.COM

def get_recipe_name(recipe: tuple[str, str]) -> str
""" Return ...
>>> get_recipe_name(...)
"""
return

in your file and then add usage examples and docstrings based on what you read below. Then completing the assignment means filling in each function properly as is done with ShiFoo. CourseNana.COM

5.1.1 num hours() -> float

This function should return the number of hours you estimate you spent (or have spent so far) on the assignment, as a float. You will not be marked differently for spending more or less time on the assignment. The purpose of this function is to enable you to verify that you understand how to submit to Gradescope as soon as possible, and to allow us to gauge difficulty level of this assignment in order to provide the best possible assistance. Ensure this function passes the relevant test on Gradescope as soon as possible. If the Gradescope tests have been released, you must ensure this function passes the relevant test before seeking help regarding Gradescope issues for any of the later functions. See Section 7.3 for instructions on how to submit your assignment to Gradescope. CourseNana.COM

5.1.2 get recipe name(recipe: tuple[str, str]) -> str

Returns the name of the recipe. CourseNana.COM

Example:
>>> get_recipe_name(('chocolate peanut butter banana shake',
'1 large banana,240 ml almond milk'))
'chocolate peanut butter banana shake'
>> get_recipe_name(('cinnamon rolls',
'480 ml almond milk,170 g Nuttelex'))
'cinnamon rolls'

5.1.3 parse ingredient(raw ingredient detail: str) -> tuple[float, str, str]

Return the ingredient breakdown from the details amount, measure, and ingredient. Example: CourseNana.COM

>>> parse_ingredient('0.5 tsp coffee granules')
(0.5, 'tsp', 'coffee granules')
>>> parse_ingredient('1 large banana')
(1.0, 'large', 'banana')

5.1.4 create recipe() -> tuple[str, str]

Return a recipe in the tuple[str, str] format after a series of prompting. The recipe name is prompted first followed by continuous ingredient prompting until an empty string is entered (enter or return key press with no text). Example: CourseNana.COM

>>> create_recipe()
Please enter the recipe name: peanut butter
Please enter an ingredient: 300 g peanuts
Please enter an ingredient: 0.5 tsp salt
Please enter an ingredient: 2 tsp oil
Please enter an ingredient:
('peanut butter', '300 g peanuts,0.5 tsp salt,2 tsp oil')

...... CourseNana.COM

5.1.13 display ingredients(shopping list: list[tuple[float, str, str]]) -> None

Print the given shopping list in any order you wish. CSSE7030 students must display the shopping list alphabetically based on the name of the ingredients. See example in Appendix. Note: The amount of spaces changes depending on how long the longest text is. The order does not matter. Example: CourseNana.COM

>>> display_ingredients([(1.0, 'large', 'banana'), (0.5, 'cup', 'ice'),])
| 1.0 | large | banana |
| 0.5 | cup
| ice
|
>>> display_ingredients([(1.0, 'large', 'banana'),
(2.0, 'tbsp', 'peanut butter'),
(2.0, 'pitted', 'dates'),
(1.0, 'tbsp', 'cacao powder'),
(240.0, 'ml', 'almond milk'),
(0.5, 'cup', 'ice'),
(1.0, 'tbsp', 'cocao nibs'),
(1.0, 'tbsp', 'flax seed')])
|
1.0 | large | banana
|
|
2.0 | tbsp
| peanut butter |
|
2.0 | pitted | dates
|
|
1.0 | tbsp
| cacao powder
|
| 240.0 |
ml
| almond milk
|
|
0.5 |
cup
| ice
|
|
1.0 | tbsp
| cocao nibs
|
|
1.0 | tbsp
| flax seed
|
Here is the output again with visile spaces.
|␣␣␣1.0␣|␣␣large␣␣|␣banana␣␣␣␣␣␣␣␣␣|
|␣␣␣2.0␣|␣␣tbsp␣␣␣|␣peanut␣butter␣␣|
|␣␣␣2.0␣|␣pitted␣␣|␣dates␣␣␣␣␣␣␣␣␣␣|
|␣␣␣1.0␣|␣␣tbsp␣␣␣|␣cacao␣powder␣␣␣|
|␣240.0␣|␣␣␣ml␣␣␣␣|␣almond␣milk␣␣␣␣|
|␣␣␣0.5␣|␣␣␣cup␣␣␣|␣ice␣␣␣␣␣␣␣␣␣␣␣␣|
|␣␣␣1.0␣|␣␣tbsp␣␣␣|␣cocao␣nibs␣␣␣␣␣|
|␣␣␣1.0␣|␣␣tbsp␣␣␣|␣flax␣seed␣␣␣␣␣␣|

5.1.14 sanitise command(command: str) -> str

Return a standardised command to all lower-case and no leading or trailing white spaces removing any numbers from the string. Example: CourseNana.COM

>>> sanitise_command('add
'add chocolate brownies'
>>> sanitise_command('add
'add chocolate brownies'
>>> sanitise_command('add
'add chocolate brownies'
>>> sanitise_command('add
'add chocolate brownies'

...... CourseNana.COM

Assessment and Marking Criteria

This assignment assesses course learning objectives: CourseNana.COM

  1. apply program constructs such as variables, selection, iteration and sub-routines,
  2. read and analyse code written by others,
  3. read and analyse a design and be able to translate the design into a working program, and
  4. apply techniques for testing and debugging.

7.1 Functionality

Your program’s functionality will be marked out of a total of 6 marks. Your assignment will be put through a series of tests and your functionality mark will be proportional to the number of tests you pass. You will be given a subset of the functionality tests before the due date for the assignment. CourseNana.COM

You may receive partial marks within each section for partially working functions, or for implementing only a few functions. You need to perform your own testing of your program to make sure that it meets all specifications given in the assignment. Only relying on the provided tests is likely to result in your program failing in some cases and you losing some functionality marks. Note: Functionality tests are automated, so string outputs need to match exactly what is expected. Your program must run in the Python interpreter (the IDLE environment). Partial solutions will be marked but if there are errors in your code that cause the interpreter to fail to execute your program, you will get zero for functionality marks. If there is a part of your code that causes the interpreter to fail, comment out the code so that the remainder can run. Your program must run using the Python 3.10 interpreter. If it runs in another environment (e.g. Python 3.8 or PyCharm) but not in the Python 3.10 interpreter, you will get zero for the functionality mark. CourseNana.COM

7.2 Code Style

The style of your assignment will be assessed by a tutor. Style will be marked according to the style rubric provided with the assignment. The style mark will be out of 4. The key consideration in marking your code style is whether the code is easy to understand. There are several aspects of code style that contribute to how easy it is to understand code. In this assignment, your code style will be assessed against the following criteria. CourseNana.COM

• Readability – Program Structure: Layout of code makes it easy to read and follow its logic. This includes using whitespace to highlight blocks of logic. – Descriptive Identifier Names: Variable, constant, and function names clearly describe what they represent in the program’s logic. Do not use Hungarian Notation for identifiers. In short, this means do not include the identifier’s type in its name, rather make the name meaningful (e.g. employee identifier). – Named Constants: Any non-trivial fixed value (literal constant) in the code is represented by a descriptive named constant (identifier). • Algorithmic Logic – Single Instance of Logic: Blocks of code should not be duplicated in your program. Any code that needs to be used multiple times should be implemented as a function. – Variable Scope: Variables should be declared locally in the function in which they are needed. Global variables should not be used. – Control Structures: Logic is structured simply and clearly through good use of control structures (e.g. loops and conditional statements). • Documentation: – Comment Clarity: Comments provide meaningful descriptions of the code. They should not repeat what is already obvious by reading the code (e.g. # Setting variable to 0). Comments should not be verbose or excessive, as this can make it difficult to follow the code. – Informative Docstrings: Every function should have a docstring that summarises its purpose. This includes describing parameters and return values (including type information) so that others can understand how to use the function correctly. – Description of Logic: All significant blocks of code should have a comment to explain how the logic works. For a small function, this would usually be the docstring. For long or complex functions, there may be different blocks of code in the function. Each of these should have an in-line comment describing the logic. CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
Python代写,CSSE1001代写,CSSE7030代写,Introduction to Software Engineering代写,Australia代写,The University of Queensland代写,Python代编,CSSE1001代编,CSSE7030代编,Introduction to Software Engineering代编,Australia代编,The University of Queensland代编,Python代考,CSSE1001代考,CSSE7030代考,Introduction to Software Engineering代考,Australia代考,The University of Queensland代考,Pythonhelp,CSSE1001help,CSSE7030help,Introduction to Software Engineeringhelp,Australiahelp,The University of Queenslandhelp,Python作业代写,CSSE1001作业代写,CSSE7030作业代写,Introduction to Software Engineering作业代写,Australia作业代写,The University of Queensland作业代写,Python编程代写,CSSE1001编程代写,CSSE7030编程代写,Introduction to Software Engineering编程代写,Australia编程代写,The University of Queensland编程代写,Pythonprogramming help,CSSE1001programming help,CSSE7030programming help,Introduction to Software Engineeringprogramming help,Australiaprogramming help,The University of Queenslandprogramming help,Pythonassignment help,CSSE1001assignment help,CSSE7030assignment help,Introduction to Software Engineeringassignment help,Australiaassignment help,The University of Queenslandassignment help,Pythonsolution,CSSE1001solution,CSSE7030solution,Introduction to Software Engineeringsolution,Australiasolution,The University of Queenslandsolution,