Please ignore secret bonuses. Secret tests do NOT award bonus. Max hw grade is 30+2 bonus efficiency

Do you need help?

Notice Board

Per partecipare al corso di Fondamenti di programmazione 2023-24 loggatevi e attivatelo nella vostra pagina dei corsi preferiti. A quel punto il corso appare nel menù personale cliccando sul proprio avatar. Per i materiali degli anni precedenti seguite lo stesso metodo.

To join the Programming/Lab 2023-24 course, log-on and select it on the my courses page. It will appear on the personal menu of your avatar. For earlier years use the same method.

[HW1opt] Can we use the formula written on the testmethod many zeros to obtain the result?

L
LiyuJin (340 points)
0 4 6
in News by (340 points)
closed by
It's been two days that I've been working on the exercise and I haven't managed to pass the last test of many_zeros.

Are we allowed to use the formula excepted=half**2 to solve the problem?

If we aren't, how could we generalize the situation?
395 views
closed

2 Answers

Best answer
yGifoom (2160 points)
0 0 20
by (2.2k points)
selected by
So long you follow the intructions (i.e. don't inport any library) you can do whatever.

If you can't get something to work be ready to change approach if needed, what sounds good in theory isn't necessarily the best practical solution
francesco.calzona (5210 points)
5 20 81
by (5.2k points)
What is the formula excepted=half**2?
L
LiyuJin (340 points)
0 4 6
by (340 points)
Testing thought the Anaconda prompt, we can see the error type and the content of test methods. Viewing the method of the many zeros test, we can see the excepted result = half **2.

So I'm wondering if we can implement something that somehow determines the structure of the list (which starts which n zeros and goes on with other subsets) and then apply the formula.

But this resolve just this case so, it's not generalised

I can't reach the solution otherwise
francesco.calzona (5210 points)
5 20 81
by (5.2k points)
As long as you correctly place conditionals, and your case is not overly-specific for that specific test, I do not see why you should not do this. Just make sure it keeps going with the most cases possible.