Description
In this lab, we now define a function (our program) with an specific name to make it easier to call and run it instead of writing everything once again, and we also gave the person more options to choose specifically an operation of preference. For the function,at the beginning of our program, we used the term “def” and named it how ever wepleased (it’s suggested to name it with something that relates to the function, to make it easier to remember, and other people to understand it.) In this case I chose to name my function “operations” after the name of my function i place a set of parenthesis “( )” that would be our parameters, followed by “:” After we defined the function, I set my conditions using a while for a main menu that gives me two options; Enter a number and Exit. I used an “If” option == 1 then the it will enter to the loop that will now ask for an specific operation in the list where the selection is based on own preference, after the selection is made, now it will ask for two values, one for X and another for Y. The operation will be solved and will show the result follow by the second menu, asking for a new selection, if option 7 happens to be the choice, then the loop will exit and go back to the first (main) menu. In the first menu, if the selection happens to be 2, then the program will exit.
Code
Screenshot