93.5k views
3 votes
Write a Python script to read two integer numbers and an arithmetic operator and display the computed result.

A. input1 = int(input("Enter first number: "))
B. num2 = int(input("Enter second number: "))
C. operator = input("Enter arithmetic operator: ")
D. result = num1 + num2

User Alwin Doss
by
8.0k points

1 Answer

3 votes

Final answer:

To write a Python script that reads two integer numbers and an arithmetic operator and displays the computed result, you can follow these steps: get the numbers and operator from the user, perform the desired operation, and display the result.

Step-by-step explanation:

To write a Python script that reads two integer numbers and an arithmetic operator and displays the computed result, you can use the following steps:

  1. Get the first number from the user using the int(input('Enter first number: ')) function and store it in a variable.
  2. Get the second number from the user using the int(input('Enter second number: ')) function and store it in another variable.
  3. Get the arithmetic operator from the user using the input('Enter arithmetic operator: ') function and store it in a variable.
  4. Perform the arithmetic operation based on the operator entered by the user. For example, if the operator is '+', you can use result = num1 + num2, if the operator is '-', you can use result = num1 - num2, and so on.
  5. Display the computed result using the print() function.
User Maulrus
by
7.9k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.