Write a program to enter two numbers and print the arithmeticoperations like +,-,*,**, /, // and % using function
Question
Write a program to enter two numbers and print the arithmetic operations like +
, -
, *
, **
, /
, //
and %
using function
Solution
Sure, here is a simple Python program that performs arithmetic operations on two numbers:
def arithmetic_operations(num1, num2):
print("Addition: ", num1 + num2)
print("Subtraction: ", num1 - num2)
print("Multiplication: ", num1 * num2)
print("Exponent: ", num1 ** num2)
print("Division: ", num1 / num2)
print("Floor Division: ", num1 // num2)
print("Modulus: ", num1 % num2)
# Test the function
arithmetic_operations(10, 2)
This program defines a function arithmetic_operations
that takes two numbers as arguments and prints the result of various arithmetic operations on them. The function is then called with the numbers 10 and 2 as arguments.
Please replace the numbers 10 and 2 with the numbers you want to perform arithmetic operations on.
Similar Questions
find the output of given code.#include <stdio.h>int main(){int a,b=110,c=20;printf("%d",a=b-=c*=5);return 0;}-1045010110
The output of the code will be ____. int i=5; printf(“%d %d %d”, i, i++, ++i); ans. 5 5 7 7 6 6 7 6 5 7 6 7
The program must accept four integers a, b, c and d as input. The program must solve the equation b * c - (a + d) and print it as the output.
What will be the output of following program?main( ){int k, num = 30 ;k = ( num > 5 ? ( num <= 10 ? 100 : 200 ) : 500 ) ;printf ( "\n%d", num ) ;}
Type the program's outputa = int(input())b = int(input())c = int(input())while a < b: print(a) if a > c: break a += 2 Input2144Output
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.