In: Computer Science
write a Python program that takes information from the user about a spider seen in North America and returns whether it is likely to be a dangerous spider. The only two spiders in North America that are actually dangerous are the widow and recluse. The program will ask the user for the following information: color and special markings.
printWelcome – prints program information
printColorMenu – Color menu options should be brown, black, other
printSpecialMarkingsMenu – Special markings options should be hour glass on underside, violin shape on head, other
main – takes in color option and returns spider information as follows:
Sample run:
Welcome to the dangerous North American spider identifier!
1. Brown
2. Black
3. Other
What color is the spider? Select 1, 2, or 3 from the menu above: 1
1. Hourglass on underside
2. Violin on head
3. Other
Does the spider have any special markings? Select 1, 2, or 3 from the menu above: 1
That is a brown widow and dangerous. Handle carefully!
Welcome to the dangerous North American spider
identifier!
1. Brown
2. Black
3. Other
What color is the spider? Select 1, 2, or 3 from the menu above: 1
1. Hourglass on underside
2. Violin on head
3. Other
Does the spider have any special markings? Select 1, 2, or 3 from the menu above: 2
That is a brown recluse and dangerous. Be careful!
Welcome to the dangerous North American spider identifier!
1. Brown
2. Black
3. Other
What color is the spider? Select 1, 2, or 3 from the menu above: 1
1. Hourglass on underside
2. Violin on head
3. Other
Does the spider have any special markings? Select 1, 2, or 3 from the menu above: 3
That is very likely not a dangerous spider.
Raw_code:
def printWelcome():
print("Welcome to the dangerous North American spider
identifier!")
def printColorMenu():
spider_colors = ("Brown", "Black", "Other")
# iterating over each color in spider_colors and printing
color
for index, color in enumerate(spider_colors):
print(index+1, color, sep = ". ")
def printSpecialMarkingsMenu():
spider_marks = ("Hourglass on underside", "violin on head",
"other")
# iterating over each mark in spider_marks and printing mark
for index, mark in enumerate(spider_marks):
print(index+1, mark, sep = ". ")
# main
if __name__ == "__main__":
printWelcome() # printing welcome
printColorMenu() # printing color menu
# taking spider color from user and storing spider_color
spider_color = int(input("What color is the spider? Select 1, 2, or
3 from the menu above: "))
printSpecialMarkingsMenu() # printing marks menu
# taking spider mark from user and storing spider_mark
spider_mark = int(input("Does the spider have any special
markings?" +
" Select 1, 2, 3 from the menu above: "))
# user if statement for checking what type of spider it is
if spider_color == 1 and spider_mark == 1:
print("That is a brown widow and dangerous. Handle
carefully!")
elif spider_color == 1 and spider_mark == 2:
print("That is a brown recluse and dangerous. Be careful!")
elif spider_color == 2 and spider_mark == 1:
print("That is a black widow and dangerous. Handle
carefully!")
else:
print("That is very likely not a dangerous spider.")