In: Computer Science
First, the Python program prompts user to enter user information (name, email, and phone number). Then it displays a menu called “Fish Information” that has the following fish type:
1. Cat Fish 2. Red Fish 3. Any other fish
Let user choose the fish type that he/she got and input the length of the fish. Then the program will determine what should be done with this particular fish. Based on the following criteria:
Criteria: Length:
FISHTYPE - Cat Fish <10: "throw back" >=10 through <=25: "keep" >25: "tag"
FISHTYPE – Red Fish <15: "throw back" >=15 through <=30: "keep" >30: "tag"
FISHTYPE – any other fish <10: "throw back" >=20: "keep"
Let the user to enter as many times they want using loops and save all the input data using List.
At the end, the program will display the user’s information and all the fish information.
Python program :
name = input("Please, enter your name: ") # ask name of user
email = input("Please, enter your email: ") # ask email of user
phone = input("Please, enter your phone number: ") # ask phone number of user
print("Menu:") # print menu for user
print("------")
print("1.Cat Fish")
print("2.Red Fish")
print("3.Any other fish")
option = int(input("Choose a fish type or 0 to exit: ")) # ask user to choose a option
data = [] # data is a list to store user information
while option!=0: # while loop to exit when option entered by user is 0
length = int(input("Enter length of fish: ")) # ask user to enter length of fish
if option == 1: # if the option is 1 then user choosed cat fish
if length<10: # check if length is less than 10
data.append("throw back")
elif length>=10 and length<=25: # check if length is in [10,25]
data.append("keep")
else: # check if length is greater than 25 and add the data accordingly
data.append("tag")
if option == 2: # if the option is 2 then user choosed red fish
if length<15:
data.append("throw back")
elif length>=15 and length<=30:
data.append("keep")
else:
data.append("tag")
if option == 3: # if the option is 3 then user choosed any other fish
if length<10:
data.append("throw back")
if length>=20:
data.append("keep")
option = int(input("Choose a fish type or 0 to exit: ")) # again ask user to choose for a option
print("\nUser information is :") # print user information
print("Name :",name)
print("Email :",email)
print("Phone Number:",phone)
print("\nFish information is :") # print fish information
n = len(data)
for i in range(n):
print(data[i])
Screenshot :