Python 3.7.4: The current calendar, called the Gregorian calendar, was introduced in 1582. Every year divisible by four was created to be a leap year, with the exception of the years ending in 00 (that is, those divisible by 100) and not divisible by 400. For ­instance, the years 1600 and 2000 are leap years, but 1700, 1800, and 1900 are not. Write a program that requests a year as input and states whether it is a leap year. We need to run this as many times as the user wants to check for leap years. --------------------------- Below is my original program.  I need to change it so that it now has a main() function plus three more functions.  Do I convert the while loop to an if loop?  The instructor said that it was a bad habit to include "break" in loops, so I was able to eliminate that.  I just don't know how I can get that many functions out of this program. ''' Determine if a given year is a leap year, running as many times as the user wants to check for leap years''' # instructionsprint('This program determines if a given year is a leap year.')year= input("Enter year or stop to exit: ") # processwhile year.upper() != "STOP":   # provides a break to the loop  if int(year) % 400 == 0:  # check if the year entered by user is a leap year or not      print(year,"is a leap year")  elif int(year) % 100 == 0:      print(year, "is not a leap year")  elif int(year)%4 == 0:      print(year,"is a leap year") # output  else:      print(year, "is not a leap year")  year= input("Enter year or stop to exit: ")  print("Thank you.")

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Python 3.7.4:

The current calendar, called the Gregorian calendar, was introduced in 1582. Every year divisible by four was created to be a leap year, with the exception of the years ending in 00 (that is, those divisible by 100) and not divisible by 400. For ­instance, the years 1600 and 2000 are leap years, but 1700, 1800, and 1900 are not. Write a program that requests a year as input and states whether it is a leap year. We need to run this as many times as the user wants to check for leap years.

---------------------------

Below is my original program.  I need to change it so that it now has a main() function plus three more functions.  Do I convert the while loop to an if loop?  The instructor said that it was a bad habit to include "break" in loops, so I was able to eliminate that.  I just don't know how I can get that many functions out of this program.

''' Determine if a given year is a leap year, running as many times as the user wants to check for leap years'''

# instructions
print('This program determines if a given year is a leap year.')
year= input("Enter year or stop to exit: ")

# process
while year.upper() != "STOP":   # provides a break to the loop
  if int(year) % 400 == 0:  # check if the year entered by user is a leap year or not
      print(year,"is a leap year")
  elif int(year) % 100 == 0:
      print(year, "is not a leap year")
  elif int(year)%4 == 0:
      print(year,"is a leap year")

# output
  else:
      print(year, "is not a leap year")
  year= input("Enter year or stop to exit: ")  
print("Thank you.")

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Files and Directory
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education