Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone help me with these two questions, please (PyCharm) Q1) (test_leap.py) The year y is a leap year if and only if: -y is

Can someone help me with these two questions, please

(PyCharm)

image text in transcribed

image text in transcribed

Q1) (test_leap.py) The year y is a leap year if and only if: -y is evenly divisible by 4, but must simultaneousely not be divisible by 100 - or if y is evenly divisible by 400. Thus, 2016 is a leap year (evenly divisible by 4 but not by 100; 1900 is NOT a leap year, since it's evenly divisible by 100 but NOT by 400; 2000 IS a leap year, since it's evenly divisible by 400. Write a PyTest program that contains a bool function named is_leap (year) which returns True if year is a leap year, and False otherwise. Then write 10 different pytest test functions, each of which tests a different year value. Try to pick a variety of both leap and non-leap years. Put both your function and your tests in the same file. Make sure there's no console input or output within your code, or pytest will complain. Remember that each pytest test function must (a) have a name that starts with test_, (b) have no arguments, and (c) provide a test of the form assert True==is_leap (YYYY) if YYYY should be a leap year, or assert False==is_leap (YYYY) if not. For this program, no main() function is needed: only the function definition and the 10 PyTest test methods. Make sure that all your tests SUCCEED! Q2) (julian.py) A Julian date is the ordinal integer number of any date within a specific year. For example, January 1 is always Julian date 1, February 1 is Julian date 32, and December 31 is Julian date 365 in non-leap years and 366 in leap years. Here's a way of calculating the Julian date value named daynum Apply integer arithmetic in the following order of calculations: (1) daynum = 31* (monthNum-1) + dayNumWithinMonth (2) If the month is after February, subtract (4 * monthNum + 23) // 10 from daynum (3) If it's a leap year and after February 29, add 1 to daynum Using this algorithm, write a function named julian (day, month, year) which returns the int Julian date (day number within the year) of its day, month and year arguments. Define a main() function which reads the date from the user as three separate int values; you don't have to verify that it's valid. Then call your function, passing the three input arguments, and print the int result in a format similar to the following: Entered day, month, year values = 31, 12, 2020 Julian day within year = 366 Hint: Use your is_leap (year) function from step [Q1] in your test for computation step (3) above

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions