I’m working on a python exercise and need an explanation and answer to help me learn.
1) Use list to create a menu. The menu will look like this
1) Add two numbers
2) Mult two number
3) Divide
4) Scalc
The menu doesn’t have to do anything, but if you want to try to take input and call your math functions from mylib.py, go for it.
2) Create a dictionary called allInOne
3) Prompt user for the two numbers (this code should already exist, along with all the error-checking)
4) Create a function the will save the results of the operation in the dictionary allInOne(n1, n2).
For example, if the user enters 5 and 2, the result of the dictionary would be: {“add”: 7, “sub” : 3, “mult”: 10, “div”: 2.5}
You will print the results and they would look like:
5 + 2 = 7
5 – 2 = 3
5 * 2 = 10
5 / 2 = 2.5


0 comments