Executive Solution Overview
**ASSIGNMENT:** **You are going to enhance the prior assignment by doing the following.** – Use list to create a menu (NOT in the library) – Add a function to the library that will return the results of the four operations in a dictionary object allInOne(n1, n2) **Here is an example of a dictionary:…
Instant Solution Download
$6.99Immediate access to the full model answer, formatted citations, and rubric breakdown.
Need a Fresh Custom Paper?
Have this question answered from scratch according to your specific instructions and deadline.
Order on TutorsGallery →Assignment Prompt & Instructions
**ASSIGNMENT:**
**You are going to enhance the prior assignment by doing the following.**
– Use list to create a menu (NOT in the library)
– Add a function to the library that will return the results of the four operations in a dictionary object allInOne(n1, n2)
**Here is an example of a dictionary:**
MLB_team = {'Colorado' : 'Rockies', 'Boston' : 'Red Sox', 'Minnesota': 'Twins', 'Milwaukee': 'Brewers',
'Seattle' : 'Mariners'
}
res=allInOne(5,2)
The results will be returned in this format.
res is dictionary {"add":7, "sub":3, "mult":10, "div":2.5)
\* You must use the function in the library.
from res, you are going to print
5 + 2 = 7
5 – 2 = 3
5 * 2 = 10
5 / 2 = 2.5
Sample menu in the program (not the library)
1) Add two numbers
2) Mult two numbers
3) Divide
4) Scalc
5) all in one ..
6) …
Submission Instructions:
Make sure that you save your code in a text file in this format.
**program:**
W6_firstname_lastname.py
**library:**
W6_firstname_lastname_Mylib.py
Hints:
1) library
"""
comment block
"""
# def functions
def add …
def sub ….
def mul
def div
def isinrange
def scalc
def allinone
2) Program
import the library as **sam** >>> use your initials <<<
while True:
try:
# set limits lr and hr
lr = input(low limit range)
hr = input(high limit range)
# get user lower range and user high range
ulr=enter user lower range between the lower limit and high limit
uhr=enter user high range between the lower limit and high limit
#check to see in ulr and uhr are in the ranges
if( **sam**.checknum(lr,ulr,hr) and **sam**.checknum(lr,uhr,hr)):
_**# Using dictionary object**_
# a dictionary is a key:value pair data structure
# Here is a simple dictionary
# empty dictionary
fruits = {} # <<< curly brackets
# dictionary with items
fruits = {"A":"Apple", "B":"Banana", "C":"Coconut"}
#print a value for a key
#from the above; A, B, and C are keys
#print the value of A
print(fruits["A"])
#print the entire dictionary
print(fruits)
#updating dictionary
fruits["C"]="Cashew"
#print the dictionary
print(fruits)
**# Creating a function that returns a dictionary**
def myfruits():
return {"A":"Apple", "B":"Banana", "C":"Coconut"}
# using the above function
dFruit = myfruits()
print(dFruit["A"]) # Apple
# function passing key to get the value
def myfruits2(k):
myfruits={"A":"Apple", "B":"Banana", "C":"Coconut"}
return myfruits[k]
# testing myfruits2
print(myfruits2("C")) # Coconut
**ADDITIONAL RESOURCES:**
In respect to List, take some time to note the following:
– Since there is no native array data structure, use List in Python.
– It may contain more than one element.
– Use a plural to name your List.
– Lists are ordered collections.
– Elements are used to build a List.
– Individual elements are separated by commas.
– Index and positions are used to access any element in the List.
– Python considers the first element in a List as zero or 0, 1 represents the second position in the List, etc.
– Use a simple counting system to decide what to add, subtract, multiply or divide.
– You may use different methods.
Using methods improves your coding efficiency. Below are some commonly used methods:
– append() – Add Single Element to The List
– extend() – Add Elements of a List to Another List
– insert() – Inserts Element to The List
– remove() – Removes Element from the List
– index() – returns smallest index of element in list
– count() – returns occurrences of element in a list
– pop() – Removes Element at Given Index
– reverse() – Reverses a List
– sort() – sorts elements of a list
– copy() – Returns Shallow Copy of a List
– clear() – Removes all Items from the List
Explore these methods in your coding while practicing. You may read more about these codes by going to – Python List Methods – https://www.programiz.com/python-programming/methods/list. Remember, much like using loops serve as a foundation for programming, using arrays also serve as a basic expectation for programming.
**Assessment Rubric**
**Exemplary (25-20)**
**Accomplished**
**(19-10)**
**Developing**
**(9-1))**
**Beginning**
**( 0)**
**Points Available**
– Assignment details in a comment block
The student **effectively** completed the assignment.
The student **partially** completed the assignment.
The student provided **limited and meaningless** substance to complete the assignment.
The student **failed** to complete the assignment.
25
– Use the list to create a menu
– Code comments
The student **effectively** completed the assignment.
The student **partially** completed the assignment.
The student provided **limited and meaningless** substance to complete the assignment.
The student **failed** to complete the assignment.
25
– Use dictionary/data structure to return more than one value from a function
– Code comments
The student **effectively** completed the assignment.
The student **partially** completed the assignment.
The student provided **limited and meaningless** substance to complete the assignment.
The student **failed** to complete the assignment.
25
– The print function used to correctly print the solution ( application is running)
The student **effectively** completed the assignment.
The student **partially** completed the assignment.
The student provided **limited and meaningless** substance to complete the assignment.
The student **failed** to complete the assignment.
25
Leave a Reply