Do you need any help?

Notice Board

Per partecipare al corso di Fondamenti di programmazione 2021-22 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 2021-22 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.

VIDEOLEZIONI DEL CORSO DI FONDAMENTI DI PROGRAMMAZIONE AA20-21

PROGRAMMING COURSE VIDEOCONFERENCES AY20-21

source code test from Additional exercises

1
1948848 (250 points)
0 3 5
asked Oct 20, 2020 in Programming in Python by 1948848 (250 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)
0 3 10
answered Oct 20, 2020 by Dario_loi (1,710 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.