grades = 'Alice': [85,90], 'Bob': [78,82], 'Charlie': [92,88] for student, scores in grades.items(): average = sum(scores) / len(scores) print(f"student: average:.1f")
def is_palindrome(word): cleaned = word.lower() return cleaned == cleaned[::-1] print(is_palindrome("Racecar")) # True code avengers answers python 2 new
Alice: 87.5 Bob: 80.0 Charlie: 90.0 Old solutions often used print() inside functions. The new curriculum enforces the single responsibility principle —functions should return values, not print. Challenge 5.1: Rectangle Calculator Prompt: “Write a function rect_area(length, width) that returns the area. Then write rect_perimeter(length, width) that returns the perimeter. Finally, call both with length=5, width=3 and print the results.” Here’s why: area = rect_area(5, 3) perimeter =
Last Updated: 2026 Difficulty Level: Beginner to Intermediate Here’s why: area = rect_area(5
The new curriculum marks as incorrect any solution that doesn’t use lower() or that prints inside the function. Troubleshooting: Common Errors in the "New" Python 2 Course Even with the correct answers, you might encounter validation errors. Here’s why:
area = rect_area(5, 3) perimeter = rect_perimeter(5, 3) print(f"Area: area, Perimeter: perimeter") Prompt: “Create a function is_palindrome(word) that returns True if the word reads the same forwards and backwards, ignoring case. Test it with 'Racecar'.”