Angles should be set by calling methods like gimbal.set_pitch(0), not by assignment.
Step 2: Identify incorrect assignments
The code uses gimbal.set_pitch = 0, which overwrites the method with an integer, causing errors.
Final Answer:
Using assignment instead of method calls -> Option A
Quick Check:
Methods need parentheses, not assignment [OK]
Hint: Use parentheses to call methods, not '=' assignment [OK]
Common Mistakes:
Assigning values to methods
Forgetting parentheses
Assuming functions are variables
5. You want to smoothly move the camera gimbal from pitch 0 to 30 degrees in 3 steps. Which code correctly implements this using a loop?
hard
A. for angle in range(0, 30):
gimbal.set_pitch(angle * 10)
B. for angle in [10, 20, 30]:
gimbal.set_pitch(angle)
C. for angle in range(0, 30, 10):
gimbal.set_pitch(angle)
D. for angle in range(0, 31, 10):
gimbal.set_pitch(angle)
Solution
Step 1: Understand the target angles
The pitch should move through 0, 10, 20, and 30 degrees in steps.
Step 2: Check each option's range
for angle in range(0, 31, 10):
gimbal.set_pitch(angle) produces angles 0, 10, 20, 30, which smoothly moves from 0 to 30 in 4 steps.
Step 3: Verify other options
for angle in [10, 20, 30]:
gimbal.set_pitch(angle) -> misses starting at 0. for angle in range(0, 30, 10):
gimbal.set_pitch(angle) -> stops at 20, missing 30. for angle in range(0, 30):
gimbal.set_pitch(angle * 10) -> incorrect values (0 to 290).
Final Answer:
for angle in range(0, 31, 10):
gimbal.set_pitch(angle) -> Option D
Quick Check:
Range includes 0 to 30 in steps of 10 [OK]
Hint: Use range with correct start, stop, and step for smooth movement [OK]