CodeSolved

Solved Programming Questions & Exercises

Power to be able

Practice Easy 249/ Download 2053 Views

Write a program that receives two integers m and n from the user andOnly with the operator of the pluralThe number m is to the power of n

11 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.
m = int(input("please enter a number: "))
n = int(input("please enter a number: "))
a = 1
for i in range(0, n):
    a *= m
print(a)

Where is the collector ???? User 35


def power_using_addition(m, n):
    # If n is negative, the result is 0
    if n < 0:
        return 0
    # If n is equal to 0, the result is 1
    elif n == 0:
        return 1
    result = 0
    for _ in range(n):
        result += m  # The sum of m to the number of n
    return result

# Get input from the user
try:
    m = int(input("عدد m را وارد کنید: "))
    n = int(input("عدد n را وارد کنید: "))
    
    # The calculation and display of the result
    result = power_using_addition(m, n)
    print(f"{m} به توان {n} برابر است با: {result}")
except ValueError:
    print("لطفاً یک عدد صحیح وارد کنید.")
Mma123 Download Python
def click(m,n):
    return f"natije = {m ** n}"
print(click(m=int(input("enter:")),n=int(input("enter:"))))
Sumy.amiri Download Python
def tavan(m,n):
    a=0
    if n==0:
        result=1
        print(result)
    elif n>m:
        print('n bayad az m kamtar basheh!') # I can't just solve this part with the collector for now
    else:
        for i in range(1,m+1):
            a+=m
        print(a)

m=int(input('m: '))
n=int(input('n: '))
tavan(m,n)
User 35 Download Python
n = int(input("n value: "))
m = int(input("m value: "))
def add(a, b):
    num = a
    for i in range(b):
        num += 1
    return num
def multiply(a, b):
    num = 0
    for i in range(b):
        num = add(num, a)
    return num
def exponent(a, b):
    num = 1
    for i in range(b):
        num = multiply(num, a)
    return num
print(exponent(n, m))
Farbod.313 Download Python
def  taha(n , m):
    return pow(n , m)

x = taha(  int(input ("enter number1: "))  ,  int(input ("enter number2 : "))  )
print(x)

User 1434 Download Python
def power_using_addition(m, n):
    """محاسبه m به توان n با استفاده از عملگر جمع."""
    if n < 0:
        return 1 / power_using_addition(m, -n)  # For n negative, we get in reverse
    elif n == 0:
        return 1  # Each numeric to power 0 is equal to 1
    else:
        result = 0
        for _ in range(n):  # n بار جمع می‌کنیم
            result += m
        return result

def main():
    try:
        m = int(input("لطفاً عدد صحیح m را وارد کنید: "))
        n = int(input("لطفاً عدد صحیح n را وارد کنید: "))
        
        result = power_using_addition(m, n)
        print(f"{m} به توان {n} برابر است با: {result}")
    
    except ValueError:
        print("لطفاً یک عدد صحیح وارد کنید.")

# Implementation of the main function
if __name__ == "__main__":
    main()
Mma123 Download Python
<< Previous page 1 2 Next page >>

Submit answer

Submitting answers is currently unavailable.

Related content

Detection using AI
×
×
Close