← Back

Python for Beginners — Proficiency Exam

15 questions · pass with 50%

  1. 1. Why create a virtual environment instead of installing every package globally?

  2. 2. What does python -m pip install some-package do that typing pip install can fail to do?

  3. 3. You cloned a project that includes requirements.txt but not a .venv folder. What should you do?

  4. 4. The user types 21 at an input() prompt. What type is the value you receive?

  5. 5. a = [1, 2]; b = a; b.append(3). What is a?

  6. 6. Which conversion is safe for the string "3.9" if you want a whole number of items?

  7. 7. You want to loop through names in a list and print each one. Which construct is the most direct?

  8. 8. Why write if user is not None and user.active instead of if user.active and user is not None?

  9. 9. count is 0 (a real measurement). What happens if you write if count: to mean "we have a count"?

  10. 10. You write names = names.sort(). What is names afterward?

  11. 11. You need to know whether an order id has already been processed, among tens of thousands of ids. Which structure fits?

  12. 12. Why can't a list be a dictionary key?

  13. 13. A function prints a total but has no return. Another function does result = that_function(). What is result?

  14. 14. Why put if __name__ == "__main__": around the code that starts your program?

  15. 15. def add_item(item, basket=[]): then two calls that each add one item to the default basket. What goes wrong?

Answer all 15 questions to submit.