21. In Python, when does an else statement execute a piece of code?

  • When the if statement contains text data
  • When the if statement contains a false condition
  • When the if statement contains a true condition
  • When the if statement contains numeric data

22. A data professional wants to define a function to calculate the area of a rectangle. What code should they begin with?

  • else area_rectangle(length, width):
  • return area_rectangle(length, width):
  • def area_rectangle(length, width):
  • if area_rectangle(length, width):

23. A data professional wants to make a Python function produce new results and save the results for later use. What keyword should they use in their code?

  • else
  • and
  • if
  • return

24. What are best practices for writing clean code? Select all that apply.

  • Modularity
  • Redundancy
  • Clarity
  • Reusability

25. Fill in the blank: Refactoring is used to create _____, which is code that is written in a way that is readable and makes its purpose clear.

  • open source code
  • immutable code
  • self-documenting code
  • branching code

26. A data professional writes the following code: print(not 4 == 'Data'). What result will Python display when they run the code?

  • Equal
  • Not equal
  • False
  • True

Leave a Reply