1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
tresset_1 [31]
3 years ago
4

The variables x and y refer to numbers. Write a code segment that prompts the user for an arithmetic operator and prints the val

ue obtained by applying that operator to x and y.

Computers and Technology
1 answer:
timama [110]3 years ago
8 0

Answer:

Here is the Python program. If you want the program in some other programming language let me know.    

x = int(input("Enter the value of x: "))

y = int(input("Enter the value of y: "))

op = input("Enter an arithmetic operator : ")

operation = 0

if op == '+':

   operation = x + y

elif op == '-':

   operation = x - y

elif op == '*':

   operation = x * y

elif op == '/':

   operation = x / y

elif op == '%':

   operation = x % y

else:

   print("Invalid Character!")

print(x, op , y, "=", operation)

Explanation:

The program prompts the user to enter the value of x and y. These values are stored in variables x and y

Then the program prompts the user to enter an arithmetic operator. op variable stores the value of operator entered by the user.

If else statement is used which checks the the character of operator ( +, - , /,  * or %) that the user inputs and performs the arithmetic operation according to the input operator. The if else part that will be executed to perform the arithmetic operation is based on the operator that the user enters. For example if the user enters / then the third elif part is executed and the value of x and y are divided.

The screen shot of output of the program is attached.

You might be interested in
What will be the output of “AAAAMMMMMHHHVV” using a file compression technique?
jeka94

Answer:

it would be amhv i think i hope it answered u'er question

Explanation:

8 0
3 years ago
Which statements about organizing messages in Outlook 2016 are true? Check all that apply. The Categories function is used for g
xenn [34]

Answer:

A. B. C. F. G.

Explanation:

5 0
3 years ago
Read 2 more answers
_____ is an example of a locally installed email client.
levacccp [35]
Gmail is an example of a locally installed email client
6 0
3 years ago
Read 2 more answers
How many people in the world
sveticcg [70]

Answer:

Around seven billion people

4 0
2 years ago
What is the supernatural condition called whereby a human transforms into a wolf?
Paraphin [41]
The supernatural condition whereby a human transforms into a wolf is called a werewolf.
4 0
3 years ago
Read 2 more answers
Other questions:
  • Date criteria are automatically enclosed in ____ when entered in a query design.
    11·1 answer
  • Identify at least five different Information Technology careers that you could pursue in your home state, and choose the three t
    10·2 answers
  • Which of the following is one of the options available on the Columns menu on the
    6·1 answer
  • What is a single-user computer?
    8·1 answer
  • A Cisco Catalyst switch has been added to support the use of multiple VLANs as part of an enterprise network. The network techni
    5·1 answer
  • Having data in a column formatted differently based on value is known as
    7·1 answer
  • Why has base 2 been accepted and used as the basis for computing?​
    8·1 answer
  • The inFS.open(str) function has a string parameter str that specifies the _____ of the file to open.
    10·1 answer
  • What science category includes physics and biology?
    14·1 answer
  • PLEASE ANSWER LAST DAY OF SCHOOL. Discussion Topic
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!