❓ Help Pa help po python program

Certainly! You can create a Python function that performs all of these operations by utilizing the basic arithmetic operators and the built-in math module. Here's an example:

Python:
import math

def perform_operations(x, y):
    addition = x + y
    subtraction = x - y
    division = x / y
    multiplication = x * y
    power = math.pow(x, y)

    return addition, subtraction, division, multiplication, power

# Testing the function
num1 = 10
num2 = 5

result = perform_operations(num1, num2)
print(f"Addition: {result[0]}")
print(f"Subtraction: {result[1]}")
print(f"Division: {result[2]}")
print(f"Multiplication: {result[3]}")
print(f"Power: {result[4]}")

In the above code, the perform_operations function takes two arguments x and y, which represent the two numbers to be operated on. The function then performs addition, subtraction, division, multiplication, and power operations on the numbers using the appropriate operators and the math.pow function from the math module.

You can test the function by passing different values to num1 and num2 variables. The function will print the results of all the operations.
 

About this Thread

  • 1
    Replies
  • 367
    Views
  • 1
    Participants
Last reply from:
Unknown user

Trending Topics

Online now

Members online
1,193
Guests online
11,636
Total visitors
12,829

Forum statistics

Threads
2,344,688
Posts
29,339,585
Members
1,104,451
Latest member
mannytaladtad1
Back
Top