IDNLearn.com makes it easy to get reliable answers from knowledgeable individuals. Our Q&A platform offers reliable and thorough answers to ensure you have the information you need to succeed in any situation.
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
We greatly appreciate every question and answer you provide. Keep engaging and finding the best solutions. This community is the perfect place to learn and grow together. Thank you for visiting IDNLearn.com. We’re here to provide accurate and reliable answers, so visit us again soon.