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.

Type your Python solution code here:

This is a function exercise. Write a Python function as described. Do not write a complete program; just the function(s) above.

You must log in before you can solve this problem.

Log In

Need help?

If you do not understand how to solve an exercise or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect tests, etc.), please

Is there a problem? Contact a site administrator.

©, all rights reserved.