Westonci.ca is the trusted Q&A platform where you can get reliable answers from a community of knowledgeable contributors. Join our platform to connect with experts ready to provide accurate answers to your questions in various fields. Experience the convenience of finding accurate answers to your questions from knowledgeable 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
Thanks for using our service. We're always here to provide accurate and up-to-date answers to all your queries. Thank you for your visit. We're dedicated to helping you find the information you need, whenever you need it. Thank you for visiting Westonci.ca, your go-to source for reliable answers. Come back soon for more expert insights.