CPSC120 Lab 5


  1. Divisors

    Create a function called print_divisors in a file called divisors.py. The function should print all of the positive integers that are divisors of a specified positive integer.

  2. Perfect Numbers

    Create a function called is_perfect_number in a file called perfect_number.py. The function should return True if the specified positive integer is a perfect number, False otherwise. A positive integer is perfect if it is the sum of all of its positive divisors, excluding itself.

  3. Date Validation

    Create a function called is_valid_date in a file called date_validation.py. The function should return True if the specified day is an actual day in the Gregorian calendar, False otherwise. The function’s parameters should specify a date as three integers, one each for the day, month, and year. A date can be invalid for multiple reasons. For example, no non-positive numbers can be used to represent a date, and the number of months in a year and days in a month are finite. Note the function should take into consideration leap years. Leap years occur almost every four years. All leap years are divisible by 4, but not all years that are divisible by 4 are leap years. Years that are divisible by 100 but not divisible by 400 are not leap years.


Submit a zip file of your code on the course Inquire site that uses your last names as the file name.