python3 from operator import add, mul def square (x): return x * x def negate(x)
ID: 3707997 • Letter: P
Question
python3
from operator import add, mul def square (x): return x * x def negate(x): return x def identity(x): return x def triple (x): return 3 * x def increment(x): return x+1 def increment_by(x, step): return x + stepExplanation / Answer
def is_perfect(n): total = 0 for i in range(1, n): if n % i == 0: total += i return total > 0 and total == n def perfect_bazinga(num): def fn(top_of_range): lst = [] for i in range(top_of_range): if is_perfect(i) and i % num == 0: lst.append("I'm Both") elif i % num == 0: lst.append('Bazinga') elif is_perfect(i): lst.append("I'm Perfect") else: lst.append(i) return lst return fn try_six = perfect_bazinga(6) print(try_six(15))
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.