can someone explain or link to a site that explains the “code complexity score”? I played with it and figured out that 1 is less complex but a google search didn’t turn up anything definitive.
Good question @Zburmaster, I was able to find this link on Stepik’s support page that briefly explains it: https://support.stepik.org/hc/en-us/articles/360000486193-Code-complexity-score
Their explanation might go over your head at this point - that’s okay. The gist of it is that the code complexity score will be lower if your code is more concise, as this allows the program to run more quickly. A variety of actions including function calls (such as
find_area(5)), assignments (such as
pi = 3.14), and conditional statements (such as
if area > 0:) will all increase your code complexity score.
Code complexity isn’t very important towards the beginning of your programming journey, so I wouldn’t worry if your code is yielding a code complexity score higher than the “best possible”, so long as it works correctly. However, if you’re making large programs, it can be the difference between your program taking 15 seconds and 3 seconds to run.
Their explanation is indeed over my head, I did make a change to my code and got it down from a 2.5 to a 2 so I figured lower is better. That equation is specific to stepik though, correct?
Yes, that equation is specific to Stepik. Complexity is usually measured by something called Big O notation, which you don’t need to worry about at this point in your learning journey.
Thanks for the question, I’m glad you were able to improve your code!
i dont understand what is going wrong with the question, i KNOW my function will produce the right answer but the program isn’t letting it through. is there a specific way the code is supposed to be input?
I just went back and looked at my answer and I see I got hung up on this for a while.
if you got the previous exercise to work, then you need to remove code from step 15 in order for step 16 to work, the prompt says not to have a user input or a print statement. just a function that returns C based on the radius that is passed to it when you call the function. it’s actually asking for something simpler than step 15__
if it isn’t getting the right answer then I suppose you could just show it so someone can see what exactly you’re doing.