Need Clarification on Python Function Question from Entry-Level Python Programmer exam question

I am currently preparing for the Entry-Level Python Programmer Certification (PCEP-30-02). As part of my preparation, I have been practicing with some Entry-Level Python Programmer Certification exam questions I got from a study site. Honestly, they have been super helpful so far. However, I came across one question that left me a bit confused, and I was hoping someone here could help break it down for me.

Here’s the question:

Which of the following functions can be invoked with two arguments?

A. def mu {none}: pass
B. def iota(level, size=0): pass
C. def kappa(level): pass
D. (lambda)(): pass

According to the site, the correct answer is B, but I had really appreciate a proper explanation of why that is. From what I understand:

  • Option B defines a function with one required argument (level) and one optional/default argument (size=0). So, calling it with two arguments is valid.
  • Option C only accepts one argument, so two would raise an error.
  • Option D is a lambda with no parameters, so that’s out too.
  • And Option A seems like invalid syntax altogether.

Is my reasoning correct?

For those who have already get Entry-Level Python Programmer Certification did you find the certification useful in real-world job opportunities or freelancing gigs? I’m learning Python for both career switching and upskilling, so I’d love to hear your thoughts.

It looks like a lambda, but it is actually a syntax error since there must not be braces around the lambda keyword. [Edit: The other two reasons mentioned by bwoodsend are correct as well, but I behaved like the Python parser and stopped reading after seeing the first error…]

The reasoning for A, B and C is correct.

1 Like

(lambda)(): pass is invalid syntax too. Brackets around the keywords (in this case, the lambda) aren’t allowed. Brackets around a lambda’s paramenters aren’t allowed either (not entirely sure why). And the body of a lambda can only be an expression whereas pass is a statement. The valid syntax that does what you’d expect the former to do would be lambda: None.

Other than that, yes. All looks good to me.

I haven’t got that (or any) certification but I can tell you that your every potential employer will ask you about your experience and coding principles and likely not even mention qualifications. For those, I’d say the biggest helpers there are programming with other people and trying to work on a piece of code you wrote a couple of weeks ago and can no longer remember how it works.

1 Like

Hello,

The best way to verify this is to open up an IDE and test it.

As you correctly stated, the second argument is optional because it has a default value. That is, if the user does not enter an explicit value when invoking the function, then the default value will be used (for this particular case, a 0).

In the example provided, if you enter a 10 and a 5, the output will be 15. On the other hand, had you only passed in a 10, then 10 would be printed because the default value for the second argument would be 0.

This implies some level of independence.

Hope this clears things up a bit.

Be aware that, unlike the similar Java certifications, these qualifications have no endorsement from the the people who own the language. Elsewhere on the boards people have commented on this.

The PI website doesn’t exactly advertise this fact. Recruiters will know these “qualifications” have no formal recognition, but ought to give you credit for the progress you made in learning, which they might test themselves. You’re obviously being thorough about it, and if the material is good and paying for an exam helps you focus, that’s ok. Just don’t think you have to spend a lot of money “qualifying”.

Most people here will not have gone this route. Usually they recommend immersing yourself some project that you find motivates you personally. This can lead to knowing a lot about the few techniques and libraries you found first, so you’re slow to fill out your experience. A course, or just a book, and other people’s code, can be useful.

1 Like