Power to be able
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
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
def inaddition(m, n): result=1 for _ in range(n): temp=0 for _ in range(m): temp+=result result=temp return result m=int(input("m:")) n=int(input("n:")) result=inaddition(m, n) print(f"{result}")
def tavan(x,y): if y==0: return 1 else: return x*tavan(x,y-1) print(tavan(10,2))
def f(a, b): if b == 0: return 1 # Each number to zero power is equal to 1 return f(a, b - 1) * a # Return by reducing b x = f(2, 3) # Calculate 2 to power 3 print(x) # Output: 8
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 ????
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("لطفاً یک عدد صحیح وارد کنید.")
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)
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))
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()
n=int(input('num:')) m=int(input('num:')) l=1 for _ in range (n): temp=0 for _ in range(m): temp+=l l=temp print(l)
Submitting answers is currently unavailable.
Write a program that gets 3 numbers and prints the most in the output
Write a program that receives the number of random numbers and its interval from the user and produces the number of random numbers. Example: Enter A Number: 10 Enter Min: 1 Enter Max: 10 9 4 6 5 2 8 1 7 9 2 2
Write a function that receives a string and returns the number of letters: To solve this question, you should not use ready-made functions for example: get_len ('code-bezan.ir') # 13
Write a program that receives a number from the user and converts to letters suppose the numbers entered between 0 and 1000000 23 ➞ Twenty Three 405 ➞ Four HundredR
Write a program that receives a solar date from the input (in the format of yyyy/mm/dd). Then convert the date to AD and print in the output
Write a program that receives an infinite number from the user and when the user entered the number 0; Print all numbers entered from large to small in the output
برای استفاده از این بخش باید وارد حساب کاربریت بشی
ورود/ثبت نام If you don’t understand the exercise or can’t solve it for any reason, that’s completely
normal—don’t worry 😊
Try checking out easier exercises and reviewing different answers
submitted by others. Gradually, you can move on to more challenging exercises. Also, your answer
might be correct even if it’s different from others.