Python 3.7.4: I'm wasting a second request for the same question because the person who answered the first one didn't pay attention to the question and won't respond to the comments. I appreciate the help, I just ask that the question gets read in its entirety before you answer it. Thank you for your help. ---------------------- The original assignment was to write a program that requests a year as input and states whether it is a leap year only using a while loop. The new assignment is to take that same program and re-write it using functions. --------------------------- Below is my original program. I need to change it so that it now has a main() function plus three more functions. It must be main() and nothing more advanced than that. The instructor said that it was a bad habit to include "break" in loops, so I was able to eliminate that. ''' 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.") --------------------------- I think that with the new program I need to use something like: def main():def isLeapYear():def close():def retry(): But I keep messing it up.
Operations
In mathematics and computer science, an operation is an event that is carried out to satisfy a given task. Basic operations of a computer system are input, processing, output, storage, and control.
Basic Operators
An operator is a symbol that indicates an operation to be performed. We are familiar with operators in mathematics; operators used in computer programming are—in many ways—similar to mathematical operators.
Division Operator
We all learnt about division—and the division operator—in school. You probably know of both these symbols as representing division:
Modulus Operator
Modulus can be represented either as (mod or modulo) in computing operation. Modulus comes under arithmetic operations. Any number or variable which produces absolute value is modulus functionality. Magnitude of any function is totally changed by modulo operator as it changes even negative value to positive.
Operators
In the realm of programming, operators refer to the symbols that perform some function. They are tasked with instructing the compiler on the type of action that needs to be performed on the values passed as operands. Operators can be used in mathematical formulas and equations. In programming languages like Python, C, and Java, a variety of operators are defined.
Python 3.7.4:
I'm wasting a second request for the same question because the person who answered the first one didn't pay attention to the question and won't respond to the comments. I appreciate the help, I just ask that the question gets read in its entirety before you answer it. Thank you for your help.
----------------------
The original assignment was to write a
---------------------------
Below is my original program. I need to change it so that it now has a main() function plus three more functions. It must be main() and nothing more advanced than that. The instructor said that it was a bad habit to include "break" in loops, so I was able to eliminate that.
''' 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.")
---------------------------
I think that with the new program I need to use something like:
def main():
def isLeapYear():
def close():
def retry():
But I keep messing it up.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images