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.

source code test from Additional exercises

1948848 (700 points)
2 7 10
in Programming in Python by (700 points)
I have tried to write all source code of Additional exercises published on TWiki. I am not sure that my code can handle different types of error nor about the coding efficiency, However, I want to know is there any way I can able to check my code and get some feedback such as HW1opt. It will be really beneficial if I get some feedback I will able to improve my code.

Thanks in advance for helping me out.

1 Answer

Dario_loi (1710 points)
1 4 10
by (1.7k points)

You can re-utilize the Radon library that we use for our assignments to calculate the cyclomatic complexity of your code (the "Intricacy" value on the leaderboard)

simply go into anaconda prompt, change directory to the one in which your script is and write:

cc yourScriptName.py -a

and it will compute the average cc of your python script.

As far as Efficiency goes, things are a bit more complicated, since if you want to utilize the assignments libraries you're gonna have to write test cases

to test your code against all by yourself, which is a bit of a hassle considered the amount of different programs we have assigned;

I instead recommend you to take a look at python profiling libraries such as timeit, that allow you to measure the speed of statements, so you can get a feeling

for which method is more optimized than the other, you can also read a bit into Time Complexity so you know which algorithms are the most optimized/how your algorithm

should behave when faced with a certain input.

Lastly to check about errors I recommend you to use the spyder debugger by setting breakpoints in your code, running it line by line and checking the variable explorer

to see if everything is behaving as expected.