Files
2022-10-12 20:18:32 -04:00

61 lines
2.4 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# %%
# File: Pease-hw3b.py
# Author: PEASE, NICHOLAS
# Date: 12 OCT 2022
# Section: 1002-LAB
# E-mail: nicholas.pease@maine.edu
# Description:
# Write a program that celebrates a favorite feature of favorite parks. Get the
# favorite feature from the user for each favorite park, until the user enters done, and
# celebrate the feature of a specified park. You should create a function that prints the
# celebratory messages for a given park. This message should identify the park and
# print the favorite thing about that park once for each 10,000 visitors in a year (round
# up so that the message prints at least once for any park, no matter how small the
# attendance). This function will need the three arguments: the name of the park, the
# favorite feature, and the attendance. You may repurpose bits of code that you wrote
# for part 4a.
# Collaboration:
# I collaborated with no one
# %%
def main():
parks = ['']
park_activities = ['']
park_visitors = ['']
user_input = ""
while user_input!='done':
user_input = input("What is one of your favorite Maine parks (or 'done' to end)?")
if user_input != "done":
user_input_activity = input("What is your favorite thing about "+user_input+"? ")
user_input_visitors = input("How many thousand people visit "+user_input+" in a year? ")
parks = listAppender(parks, user_input)
park_activities = listAppender(park_activities, user_input_activity)
park_visitors = listAppender(park_visitors, user_input_visitors)
user_input_celebrate = int(input("Which park to celebrate (between 0 and "+str(len(parks)-1)+")? "))
celebratePark(parks[user_input_celebrate], park_activities[user_input_celebrate], park_visitors[user_input_celebrate])
main()
# %%
def celebratePark(park, activity, visitors):
print("At "+park+", I love the:")
print(activity+"!")
iterations = (int(visitors) // 10)
for i in range(0,iterations-1):
print(activity+"!")
# %%
# Again, I know there is a better way. I am just using the things I have been taught. (.append)
def listAppender(parks, user_input):
length = len(parks)
if length == 1 and parks[0] == "":
temp_list = ['']*(length)
temp_list[0] = user_input
else:
temp_list = ['']*(length + 1)
for i in range(0,length):
temp_list[i] = parks[i]
temp_list[-1] = user_input
return temp_list