Get reliable answers to your questions at Westonci.ca, where our knowledgeable community is always ready to help. Explore comprehensive solutions to your questions from knowledgeable professionals across various fields on our platform. Get quick and reliable solutions to your questions from a community of experienced experts on our platform.
Sagot :
In this exercise we have to use the knowledge in computational language in python to write the following code:
What is input?
Python's input function takes a single parameter which is a string. This string is often called a prompt because it contains informational text that tells the user to type something. For example, you can call the input function as follows:
So in an easier way we have that the code is:
eventName = []
eventMonth = []
eventDay = []
eventYear = []
def addEvent():
userEventName = input("What is the event: ")
userEventMonth = int(input("What is the month (number): "))
userEventDay = int(input("What is the date: "))
userEventYear = int(input("What is the year: "))
userEventMonth = validateMonth(userEventMonth)
userEventDay = validateDay(userEventMonth, userEventDay, userEventYear)
eventName.append(userEventName)
eventMonth.append(userEventMonth)
eventDay.append(userEventDay)
eventYear.append(userEventYear)
def validateMonth(month):
if month >= 1 and month <= 12:
return month
else:
return 1
def validateDay(month,day,year):
if day < 1 or day > 31:
return 1
if month == 2:
isleap = False
if year%4 == 0:
if year%100 == 0:
if year%400 == 0:
isleap = True
else:
isleap = True
if isleap:
if day <30:
return day
else:
return 1
else:
if day < 29:
return day
else:
return 1
if month in [1,3,5,7,8,10,12]:
return day
if month in [4,6,9,11] and day < 31:
return day
else:
return 1
def printEvents():
print("EVENTS")
months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
for index in range(len(eventName)):
print(eventName[index])
print("Date: "+months[eventMonth[index] -1]+ " " + str(eventDay[index]) + ", " + str(eventYear[index]))
userChoice = "yes"
while userChoice.upper() != "NO":
addEvent()
userChoice = input("Do you want to enter another event? NO to stop: ")
printEvents()
See more about python at brainly.com/question/18502436
Thank you for choosing our platform. We're dedicated to providing the best answers for all your questions. Visit us again. Thanks for using our service. We're always here to provide accurate and up-to-date answers to all your queries. Discover more at Westonci.ca. Return for the latest expert answers and updates on various topics.