Computer Science, asked by dkdarshana03, 7 months ago

pls answer this question
this program is based on python functions
Answer using the python functions
NO SPAM ​

Attachments:

Answers

Answered by poojan
7

Language Used : Python Programming (IDLE)

Note : The code written in the bold letters is the function that computes and returns the needed arithmetic operations. I have attached the interpretation and execution of the code, below, as attachments.

Program :

number1=int(input("Enter number 1: "))

number2=int(input("Enter number 2: "))

def arithoper(number1,number2):

   addition=number1+number2

   subtraction=number1-number2

   multiplication=number1*number2

   division=number1/number2

   modulodivision=number1%number2

   return addition,subtraction,multiplication,division,modulodivision

a,b,c,d,e=arithoper(number1,number2)

print("Sum of given numbers:",a)

print("Subtraction of given numbers:",b)

print("Product of given numbers:",c)

print("Division of given numbers:",d)

print("Modulo of given numbers:",e)

     

Input :

Enter number 1: 13

Enter number 2: 7

Output :

Sum of given numbers: 20

Subtraction of given numbers: 6

Product of given numbers: 91

Division of given numbers: 1.8571428571428572

Modulo of given numbers: 6

Hope it helps. If yes, leave a smile. :)

Attachments:
Answered by Anonymous
29

Here is a program:

Num1 = int(input("Enter the first number: ")

Num2 = int(input("Enter the second number: ")

def arithmetic_operation(Num1, Num2)

 Addition = Num1+Num2

 Subtraction = Num1-Num2

 Multiplication = Num1*Num2

 Division = Num1/Num2

 Modulo = Num1%Num2

 return Addition, Subtraction, Multiplication, Division, Modulo

A,B,C,D,E = arithmetic_operation(Num1, Num2)

print("Sum of given numbers is: ", A)

print("Subtraction of given numbers is: ", B)

print("Multiplication of given numbers is: ", C)

print("Division of given numbers is: ", D)

print("Modulos division of given numbers is: ", E)

Here is an output of the given program:

Input:

Enter the first number: 16

Enter the second number: 4

Output:

Sum of given numbers is: 20

Subtraction of given numbers is: 12

Product of given numbers is: 64

Division of given numbers is: 4

Modulus division of given numbers is: 0

Explanation of the given program:

  • Initially, we asked the user for entering the numbers.
  • Then we declared a function and incremented the input values in it.
  • Then we wrote simple arithmetic functions and returned them.
  • For the sake of convenience, we called the input numbers to A,B,C,D,E.
  • Then we run simply write python code using Print(). And hence, We get the results.

Some important tips:

  • If you copy-paste the above code in Python editor or IDLE, then the code will not run properly.
  • You must indent the code properly in order to run the code properly. Indention means, calling a specific function or result in a specific function.
  • Don't forget using int() function to get the user input in the form of integer. If we didn't use the int function while taking input, All program will get wrong.
Similar questions