Multiplication
Write a program that receives n and m numbers from the input and multiply n by M.For this exercise you can only use the (+) operator
Write a program that receives n and m numbers from the input and multiply n by M.For this exercise you can only use the (+) operator
let msg = 'error' alert(msg)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
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
def addition(n, m): result = 0 for _ in range(m): result += n return result n = int(input("n:")) m = int(input("m:")) result =addition(n, m) print(f"{result}")
class Multiple: def __init__(self, n, m): try: self.__n = int(n) self.__m = int(m) except ValueError: print("Enter number!") def play(self): size = 0 for _ in range(self.__m): if self.__m == 0 or self.__n == 0: self.__n == 0 elif self.__m > 1 and self.__n > 1: size += self.__n elif self.__n == 1: size = 1 elif self.__m == 1: size = self.__n self.__n = size print(self.__n) def main(): num = Multiple(input("Enter the number: "), input("Enter multipling number: ")) num.play() if __name__ == "__main__": main()
n = int(input("enter num1: ")) m = int(input("enter num2: ")) sum, i = 0, 0 while i < n: sum += m i += 1 print(sum)
n = int(input("number1:")) m = int(input("number2:")) r=0 for i in range(1,m+1): r=r+n print(n,"*",m,"=",r)
n,m = int(input('n:')),int(input('m:')) x=0 for i in range(1,m+1): x+=n print(n,'*',m,'=',x)
int(input("enter n,m") if (n==0) or (m==0): sum=0 if (n<=m): return:sum=sum+m n=n_1 if n>0: go to return
def multiply_numbers(m,n): a = 0 for _ in range(n): a += m print(a) def perform_calculations(): m = int(input("")) n = int(input("")) multiply_numbers(m,n) perform_calculations()
Submitting answers is currently unavailable.
برای استفاده از این بخش باید وارد حساب کاربریت بشی
ورود/ثبت نام 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.