Computer Science, asked by ericalexander2018, 10 months ago

Write a program to show all the arithmetic operations +,-, *, /, //, %, ** in python

Answers

Answered by manjulanagarajan007
8

Answer:

a = 21

b = 10

c = 0

c = a + b

print "Line 1 - Value of c is ", c

c = a - b

print "Line 2 - Value of c is ", c  

c = a * b

print "Line 3 - Value of c is ", c  

c = a / b

print "Line 4 - Value of c is ", c  

c = a % b

print "Line 5 - Value of c is ", c

a = 2

b = 3

c = a**b  

print "Line 6 - Value of c is ", c

a = 10

b = 5

c = a//b  

print "Line 7 - Value of c is ", c

Explanation:

Answered by Anonymous
2

Arithmetic operations

Arithmetic operators are used with numeric values to perform common mathematical operations:

\boxed{\begin{array}{c|c|c}\bf{\underline{ \: \: Operator \: \: }}&\bf{\underline{ \: \: N{a}me \: \: }} & \bf{\underline{ \: \: Example \: \: }} \\ \\+ & \tt{Addition} & \tt{x + y} \\ \\ - & \tt{Subtraction} & \tt{x - y} \\ \\ * & \tt{Multiplication} & \tt{x * y} \\ \\ / & \tt{Division} & \tt{x / y} \\ \\ \% & \tt{Modulus} & \tt{x \% y} \\ \\ * * & \tt{Exponentiation} & \tt{x * * y} \\ \\ // & \tt{Floor \; division} & \tt{x // y} \\ \\\end{array}}

In this program, we'll show how to print out all the arithmetic operations on the screen.

In order to accomplish this, we need to take user input to accept numbers. We store them as float values. Then, we calculate the arithmetic operators using the formula and display it.

PROGRAM:

a = float(input("Enter a number: "))

b = float(input("Enter a number: "))

print(f"{a} + {b} = {a+b}")

print(f"{a} - {b} = {a-b}")

print(f"{a} * {b} = {a*b}")

print(f"{a} / {b} = {a/b}")

print(f"{a} // {b} = {a//b}")

print(f"{a}^{b} = {a* *b}")

OUTPUT:

\texttt{Enter a number:} 4

\texttt{Enter a number:} 5

4.0 + 5.0 = 9.0

4.0 - 5.0 = -1.0

4.0 * 5.0 = 20.0

4.0 / 5.0 = 0.8

4.0 // 5.0 = 0.0

4.0^5.0 = 1024.0

Attachments:
Similar questions