logo CodeStepByStep logo

zune_bug

Language/Type: Python boolean logic errors while loops

The following code is a slightly modified version of actual code that was in the Microsoft Zune music player in 2008. The code attempts to calculate today's date by determining how many years and days have passed since 1980. The days parameter represents today's date as the total number of days since 1980. Assume the existence of an is_leap_year function that returns whether a given year is a leap year.

Thousands of Zune players locked up at the very end of 2008, which was a leap year. (Microsoft quickly released a patch to fix the problem.) What is the problem with the preceding code, and in what cases will it exhibit incorrect behavior? Fix the code to always return the correct date.

Function: Write a Python function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.