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.

Adding new functions to the homework

Amirreza (420 points)
1 8 11
in HW4 by (420 points)
closed by
Is it allowed to add new functions other than the main function for mandatory homework number 4? I mean I need to define two other functions, which are not directly part of the main function. Then I call them in the main function named def most_frequent_chars(filename: str) -> str: .
333 views
closed with the note: point taken

3 Answers

Cigo (5050 points)
3 6 48
by (5.1k points)
Yes, you can.

It's really useful to divide your function in smaller functions, and without doing it you wouldn't be able to pass intricacy test.
Amirreza (420 points)
1 8 11
by (420 points)
Thank you
but other functions are not sub-functions of the main function. they are defined outside the most_frequent_chars function and called within it. is that ok?
Cigo (5050 points)
3 6 48
by (5.1k points)
Yeah yeah of course, the functions are outside and you call them from the main one.
Beray Nil Atabey (7510 points)
13 33 97
by (7.5k points)
Yes, that's more than ok, we are encouraged to split our problems into smaller problems. Divide and conquer!
francesco.calzona (5210 points)
5 20 81
by (5.2k points)
It is possible and strongly recommended, as it will lower your code intricacy (which is necessary, since there is a dedicated test) and, more generally, it is a positive coding habit.