Cześć,
Wykupiłam sobie kurs pythona dla początkujących na platformie by się trochę rozwinąć :) jestem mega zielona i bawie się w to dopiero kilka dni. Kurs polega na tym by dopiero po zrobieniu każdego zadania można dostać nowa teorie i nowe zadania. Z tym zadaniem mecze się już ponad dobę i nie mogę zrobić nic innego na platformie. Czy ktoś mnie poratuje i podpowie jak mam to zrobić. Wiem, ze nie można prosić o gotowe rozwiązania, ale ja jestem zdesperowana.
Prevent cheating
On Hyperskill, we sometimes need to check that the student's code doesn't use a particular method. For instance, when the task is to manually implement the factorial computation instead of using the factorial() function from the mathmodule. How could we do that?
It is straightforward. We can override math.factorial() to do something else — raise an error or print a message to the student. To do so, first, we define a function that does what we want (for example, prints a message) with the same arguments (since we want to disguise our new function as the original one). Then, outside this new function body, we need to assign it to math.factorial this way: math.factorial = new_math_factorial (pay attention to the absence of parentheses). Now, if the student tries to use math.factorial, our custom function will be raised. It happens because when multiple functions with the same name exist, the later one always overrides the prior.
In this task, you are a content creator at Hyperskill. Implement the example with the factorial yourself. Your program should override math.factorial() and make it printthe message Don't cheat! instead of calculating a factorial. You don't need to call anything.
Kod zaczyna się od:
Import math.
Pomocy!
i dziękuje jeśli ktoś się zlituje !
Asia