Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

use python Write a program that obtains two integer numbers from the user. It wi

ID: 3631059 • Letter: U

Question

use python

Write a program that obtains two integer numbers from the user.
It will print out the sum of those numbers.
Pseudo code:
Prompt the user to enter the first integer
Prompt the user to enter a second integer
Compute the sum of the two user inputs
Display an output prompt that explains the answer as the sum
Display the result
In this project, create the pseudo code from the following request.You may use any scripting language to do this assignment.
1. The program must have some sort of menu that allows users to make selections to do a particular calculation
2. must provide at least five menu items that allow the user to make a calculation
3. Once the user makes a calculation, he/she will return to the main menu.

Explanation / Answer

Please rate - thanks

def theMenu():
    print("""
    1. Sum of two numbers
    2. Subtract two numbers
    3. Average two numbers
    4. Multiply two numbers
    5. Divide two numbers
    6. Exit
    """)

def inputSelection():
    theMenu()
    selection = int( raw_input('Make a selection: ') )
    return selection

def doSelection( selection ):
    if ( selection == 1 ):
        a1 = int( raw_input('What is the first number? ') )
        a2 = int( raw_input('What is the second number? ') )
        print('The sum of ' + str(a1) + ' and ' + str(a2) + ' is ' + str(a1 + a2))
        return
    elif ( selection == 2 ):
        a1 = int( raw_input('What is the first number? ') )
        a2 = int( raw_input('What is the second number? ') )
        print('The substraction of ' + str(a1) + ' and ' + str(a2) + ' is ' + str(a1 - a2))
        return
    elif ( selection == 3 ):
        a1 = int( raw_input('What is the first number? ') )
        a2 = int( raw_input('What is the second number? ') )
        print('The average of ' + str(a1) + ' and ' + str(a2) + ' is ' + str( (a1 + a2) / 2. ) )
        return
    elif ( selection == 4 ):
        a1 = int( raw_input('What is the first number? ') )
        a2 = int( raw_input('What is the second number? ') )
        print('The product of ' + str(a1) + ' and ' + str(a2) + ' is ' + str( a1 * a2 ) )
        return
    elif ( selection == 5 ):
        a1 = int( raw_input('What is the first number? ') )
        a2 = int( raw_input('What is the second number? ') )
        print(str(a1) + ' divided by ' + str(a2) + ' is ' + str( a1 * 1. / a2 ) )
        return
    elif ( selection == 6 ):
        exit()
    else:
        print('** Incorrect selection. ** Please make a new selection. **')

while (1):
    selection = inputSelection()
    doSelection( selection )

Create a file script.py that contains the above. Notice the blank lines, including the last blank line. Simply type this command:

python script.py

Here's what follows where I selected 1, then I entered the numbers 5 and 4:

    1. Sum of two numbers
    2. Subtract two numbers
    3. Average two numbers
    4. Multiply two numbers
    5. Divide two numbers
    6. Exit
   
Make a selection: 1
What is the first number? 5
What is the second number? 4
The sum of 5 and 4 is 9

    1. Sum of two numbers
    2. Subtract two numbers
    3. Average two numbers
    4. Multiply two numbers
    5. Divide two numbers
    6. Exit
   
Make a selection: