I have an assignment and couldn't figure out the true solution.
def triple(n): #multiplies number with 3
return (n*3)
def square(n):
return (n**2) #takes second power of number
for i in range(1,11):
if triple(i) > square(i):
print((f"triple({i})=={triple(i)} square({i})=={square(i)}"))
triple(1)==3 square(1)==1
triple(2)==6 square(2)==4
I should stop the iteration when the square of a value is larger than the triple of the value, without printing anything in the last iteration.
And both functions triple and square are must called exactly once per iteration.
other things i tried
ls =[f"triple({i})=={triple(i)} square({i})=={square(i)}" for i in range(1,11) if triple(i) > square(i)]
for i in ls:
print(i)
There is a test that checks my answers and it says "wrong number of printed lines", I asked someone from course they just told me that ı should store the values getting from each functions into a variable. And these are what I tried to do what they said