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.
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 2 numbers as the interval, in which the interval of all the 5 existing numbers. For example, in the interval of 1 to 20 the number 2 times the number 5 repeated (5 and 15)
Write a program that translates the following words from Farsi to English and vice versa. The program must be implemented infinitely and it is possible to add new words easily words: Hello = hello goodbye = bye Kata ...
Write a program that gets the user's date of birth and determines how many years, months and a few days have passed since his birthday
We want to open the cow door, we don't know the password, but we have the following information: the second -digit safing password and the fifth digit equivalent to the first number of the first digit of a larger unit ...
CSS code to select all the following elements at once and change their background color to yellow<div class="yellow" id="box"></div><div class="yellow"></div><div class="yellow mybox"></div>Footer call to action
برای استفاده از این بخش باید وارد حساب کاربریت بشی
ورود/ثبت نام 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.