In: Computer Science
Objective: The purpose of this assignment is to introduce declaration of list objects, the forstatement and the def keyword used to define functions.
Problem: Write a Python module (a text file containing valid Python code) named p3.py. This file will contain the following.
Definition of a list containing strings which are in turn integers. These integers represent years, which will be used as inputs to the next item in the file
Definition of a function named isLeap. This function must accept a string containing an integer that will be interpreted by this function as a year. If the year is prior to the introduction of the Gregorian calendar, it will print “Not Gregorian.” If the year is aGregorian year and a leap year, it will print “Leap year!”. If the year is a Gregorian year butnot a leap year, it will print “Not a leap year!”.
A for loop that will call isLeap with each of the year strings in the list of year strings defined above.
While you are free to use any name for your list of year strings, you must use the name isLeap for the function.
Submission: Submit the code you write in a text file named p3.py to the Blackboard folder for this assignment.
Also –
As you implement the code for this assignment, consider what might be added to the testing process and program output to make it clearer what the unit testing is accomplishing. For up to five points extra credit, you also submit a Word document describing any improvements you think would help in testing the function you created, including any additional output that would be useful or testing cycles.
Here i have Written the code in python text file and save the file as p3.py
After saving the file now open a new python notebook
Now run the file using the codde %run p3.py
You can try in different ways :
BY wrtting the code in the python promt as text file and run the code