The average function of infinite number of numbers
Write a function that receives infinite parameter and returns the mean numbers
If the parameter was the non -extent
Write a function that receives infinite parameter and returns the mean numbers
If the parameter was the non -extent
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 calcaverage(): while True: num = input('Enter number:') if num == '0': break if num.replace(".", "").isnumeric(): list.append(float(num)) return sum(list)/len(list) if (list) else 'Enter at least one non-zero number' list = [] print(calcaverage())
def calculate_average(*args): total = 0 count = 0 for value in args: if isinstance(value, (int, float)): # Check whether the amount of numeric is total += value count += 1 # Calculate the mean if count == 0: return 0 # If there were no numbers, the average of zero would be return total / count # Example of the use of function average = calculate_average(10, 20, 30, 'a', None, 15.5, 5) print(f"میانگین اعداد: {average}")
return=num=int(input("Enter"[0: ]) if num is "str": print("invaliable") go to return: avrage="num"/len(num)
def calculate_average(*args): # Filtering numeric parameters numeric_values = [arg for arg in args if isinstance(arg, (int, float))] # Calculate the mean if there is a numeric value if numeric_values: return sum(numeric_values) / len(numeric_values) else: return 0 # If there is no numeric value, the average of zero will be returned
numbers = 0 numbersadded = 0 while True: num = int(input("number: ")) if num == 0: break numbersadded += 1 numbers += num def allnumber(*numberss): for number in numberss: return number / numbersadded print(allnumber(numbers))
def numbers(): x = 0 y = 0 while True : a = input("Enter :") try: N = float(a) except: continue if N == 0: break x += 1 y += N return y/x avg = numbers() print(avg)
def ave(num): s = 0 for i in range(len(num)): s += num[i] return s/len(num) numbers = [] while 1: try: number = input('enter a number: ') if number == '': print(ave(numbers)) break numbers.append(int(number)) except ValueError: pass
Submitting answers is currently unavailable.
We want to open a cow door, we don't know the safety password, but we have the following information: the second -digit safing password is the first number of the first digit, the last 4th of the person in one unit is smaller than their first digit ...
Write a program that receives the user's age from the input and checks that if the user was younger than 1, it would be a throw/raise error, otherwise print a welcome message
برای استفاده از این بخش باید وارد حساب کاربریت بشی
ورود/ثبت نام 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.