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 a():
s = 0
x = 0
while True:
try:
b = int(input("num:"))
if b == -1:
break
s += b
x += 1
except ValueError:
print("input no number")
return s / x
print(a())
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)
Submitting answers is currently unavailable.
Write a function that receives a text and returns the first 100 characters with "..." if the text is longer than 100 characters. Otherwise it will restore the whole text unchanged.
Write a program that prints the number of number multiplying numbers 1 to 10
CSS Code Write to select the DIV below and change the color of the texts inside to green<div id="mybox">code-bezan.ir</div>
You must be logged in to access this section.
Login/Sign up 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.