Untitled
user_8544043
python
2 years ago
1.1 kB
21
Indexable
numbers = [] x = None def one(x): while x != 0: x = int(input("Number: ")) if x != 0: numbers.append(x) # https://stackoverflow.com/questions/57025836/how-to-check-if-a-given-number-is-a-power-of-two # https://stackoverflow.com/questions/600293/how-to-check-if-a-number-is-a-power-of-2 pows = [i for i in numbers if (i & (i - 1)) == 0] if len(pows): ans = sum(pows)/len(pows) print(ans) else: print("нет") def two(x): while x != 0: x = int(input("Number: ")) if x != 0: numbers.append(x) pows = [i for i in numbers if (9 < i < 100) and (i % 5 == 0)] if len(pows): ans = sum(pows)/len(pows) print(ans) else: print("нет") def three(x): while x != 0: x = int(input("Number: ")) if x != 0: numbers.append(x) pows = [i for i in numbers if (i % 10 == 1) and (i % 3 == 0)] if len(pows): ans = sum(pows)/len(pows) print(ans) else: print("нет") # one(x) # two(x) three(x)
Editor is loading...