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
⚠️JAVA⚠️<br> how did the output come like this ?
Morgarella [4.7K]
The first %d is the result of num 1 /bum 2
7 0
3 years ago
Which of the following is NOT a factor of identifying graphic design?
kolezko [41]

Answer:

i think it is a

Explanation:

sorry if it is wrong

4 0
3 years ago
Read 2 more answers
January 19/May 16 2022
fenix001 [56]

Answer:

This should get you started. Many things could be improved. You could keep adding layers to this program if you wanted to, so I wrote it with that in mind.

The new salary depends on the employee's department and current salary. I created a class that represents each employee. The function looks at the employee's current salary, and looks up what the employee's department raise will be (using the dictionary/hash table) before performing the calculation.

3 0
2 years ago
Source code is one particular representation of a software system. It highlights some details and hides others. This is a good e
grigory [225]

Answer:

Abstraction

Explanation:

Under fundamental principles of software engineering, the term "abstraction" is simply defined as the act of highlighting some details and hiding other ones.

Thus, the correct answer among the options is Abstraction.

8 0
3 years ago
What type of device does a computer turn to first when attempting to make contact with a host with a known IP address on another
mihalych1998 [28]

Answer: the DNS server

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • Where is the bubble level on a tripod?
    6·2 answers
  • Assume you're using a three button mouse. to access shortcut menus you would
    10·1 answer
  • Activities that scan network locales for active systems and then identify the network services offered by the host systems is kn
    12·1 answer
  • According to the ________ definition of organizations, an organization is seen as a means by which primary production factors ar
    14·1 answer
  • The outstanding disk requests are for tracks 6,10,4,20,36,8, and 40 in that order. Assume that the seek time speed is 5 msec/tra
    14·1 answer
  • Convert 1001101012 to base 10
    5·1 answer
  • Chunking is a good strategy for completing large assignments because it makes the work
    7·2 answers
  • How long will it take Lola to travel from Paris to nice?
    8·1 answer
  • Join the class <br> The class code is hello112
    5·2 answers
  • 14 Copy a picture of a crane on the next page. Do not trace them. Make a freehand sketch. (2) 2 Look at the placed where the Mar
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!