CodeSolved

Solved Programming Questions & Exercises

Power calculation function

Practice Easy 8/ Download 2019 Views

Write a function that receives 2 numbers as parameter (A and B) and get A to power B and return

15 Answers

This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
class Math:
	def __init__(self, numer1,number2):
		self.number1=number1
		self.number2=number2
	def Soulotion(self):
		return self.number1**number2
number1=int(input("enter your number1:"))
number2=int(input("enter your number2:"))
obj=Math(number1,number2)
print(obj.Soulotion())
Roghaye.m Download Python
def tavan(a , b):
    tavan = a**b
    print(tavan)

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

tavan(num , tawan)

User 3382 Download Python
def power(a, b):
    t = 1
    for i in range(b):
        t *= a
    return t
print(power(2, 4))
User 720 Download Python
def tavan(a,b):
    return a ** b
num1 = int(input('number 1 : '))
num2 = int(input('number 2 : '))
print(tavan(num1,num2))
a=int(input("enter your number:"))
b=int(input("enter your number:"))
x=(a**b)
x=str(x)
print('a power b =' + " " + x)
Omid.asadi Download Python
def power(a, b):
    return a ** b  # Calculate A to power b

# Example to use the function
try:
    a = float(input("عدد a را وارد کنید: "))
    b = int(input("عدد b را وارد کنید: "))
    
    result = power(a, b)
    print(f"{a} به توان {b} برابر است با: {result}")
except ValueError:
    print("لطفاً یک عدد صحیح برای b و یک عدد برای a وارد کنید.")
Mma123 Download Python
def exponentiation():
    num1 = float (input ('Enter the number1: '))
    num2 = float (input ('Enter the number2: '))
    power = num1 ** num2
    return power
exponentiation()
<< Previous page 1 2 Next page >>

Submit answer

Submitting answers is currently unavailable.

Related content

Detection using AI
×
×
Close