Module 2 challenge :Get Started with Python (Google Advanced Data Analytics Professional Certificate) Answers 2025
Question 1
To define a function to calculate area of a rectangle, they should begin with:
-
def area_rectangle(length, width): ✅
-
return area_rectangle(length, width): ❌
-
else area_rectangle(length, width): ❌
-
if area_rectangle(length, width): ❌
Explanation:
All Python functions must begin with def function_name(parameters):.
Question 2
Fill in the blank:
A data professional uses the _____ keyword to make a function produce and save results.
-
else ❌
-
def ❌
-
return ✅
-
if ❌
Explanation:return outputs a value from a function.
Question 3
Best practices for writing clean code (Select all):
-
Modularity ✅
-
Clarity ✅
-
Redundancy ❌
-
Reusability ✅
Explanation:
Clean code is modular, clear, and reusable — redundancy should be avoided.
Question 4
Restructuring code while keeping the same functionality is:
-
Reprogramming ❌
-
Converting ❌
-
Refactoring ✅
-
Branching ❌
Explanation:
Refactoring improves structure without changing behavior.
Question 5
Purpose of a docstring:
-
Make the function produce new results ❌
-
Define the function ❌
-
Summarize the function’s behavior and explain arguments + return values ✅
-
Run the function ❌
Explanation:
A docstring documents what the function does.
Question 6
Python comparator for “less than or equal to”:
-
= ❌
-
== ❌
-
!= ❌
-
<= ✅
Explanation:<= is the correct operator.
Question 7
print(23 > 32 and 7 != 5) outputs:
-
False ✅
-
Not equal ❌
-
True ❌
-
Equal ❌
Explanation:
23 > 32 → False
7 != 5 → True
(False AND True) → False
Question 8
An if statement executes code:
-
When the condition evaluates to equal ❌
-
When the condition evaluates to true ✅
-
When the condition evaluates to false ❌
-
When the condition evaluates to not equal ❌
Explanation:
Python executes the if block only when the condition is True.
Question 9
An else statement executes code:
-
When the if statement contains a false condition ✅
-
When the if contains a true condition ❌
-
When the if contains numeric data ❌
-
When the if contains text ❌
Explanation:else runs only if the if condition evaluates to False.
Question 10
Which code yields identical results to:
def is_odd(x):
if x % 2 == 0:
return False
else:
return True
Correct answer:
-
def is_odd(x):
if x % 2 == 0:
return False
return True ✅
Other options:
-
return False if … ❌ (syntax error)
-
return True then if … ❌ (unreachable code)
-
indentation errors ❌
Explanation:
Removing else but placing return True after the if gives the same behavior.
🧾 Summary Table
| Q# | Correct Answer |
|---|---|
| 1 | def area_rectangle(length, width): |
| 2 | return |
| 3 | Modularity, Clarity, Reusability |
| 4 | Refactoring |
| 5 | Docstring explains behavior |
| 6 | <= |
| 7 | False |
| 8 | When condition is true |
| 9 | When if condition is false |
| 10 | If-even-return-False-else-return-True equivalent |