Question

In: Computer Science

write a Python program that takes information from the user about a spider seen in North...

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:

  • Brown and hourglass on underside: brown widow is dangerous
  • Black and hourglass on underside: black widow is dangerous
  • Brown and violin shape on head: brown recluse is dangerous
  • Other selected for color or special markings: likely not dangerous

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.

Solutions

Expert Solution

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.")


Related Solutions

Write a Python program that takes information from the user about a spider seen in North...
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...
how to write a cpp program that takes a number from a user, and print the...
how to write a cpp program that takes a number from a user, and print the sum of all numbers from one to that number on screen? using loop interation as basic as possible.
Write a program that takes a string input from the user and then outputs the first...
Write a program that takes a string input from the user and then outputs the first character, then the first two, then the first three, etc until it prints the entire word. After going up to the full word, go back down to a single letter. LastNameUpDown. Input: Kean Output: K Ke Kea Kean Kea Ke K
In python. Projectile motion: Write a python program that will ask the user for      an...
In python. Projectile motion: Write a python program that will ask the user for      an initial height y0, initial velocity v, launch angle theta, and mass m.      Create two functions, one that will calculate max height      of the projectile, and one that will calculate the range. Ask the     user which one he/she would like to calculate, then present them with the answer. (use kg, m and m/s)
Calculating Delivery Cost Program in Python write a program in Python that will ask a user...
Calculating Delivery Cost Program in Python write a program in Python that will ask a user to enter the purchase total, the number of the items that need to be delivered and delivery day. Then the system displays the cost of delivery along with the total cost. Purchase total > $150 Yes Number of the items (N) N<=5 N>=6 Delivery day Same Day Next Day Same Day Next Day Delivery charges ($) 8 N * 1.50 N * 2.50 N...
Python: Write a program that asks the user for the name of a file. The program...
Python: Write a program that asks the user for the name of a file. The program should display the contents of the file line by line.
Write a Java program that takes an array of 10 "Int" values from the user and...
Write a Java program that takes an array of 10 "Int" values from the user and determines if all the values are distinct or not. Return TRUE if all the values of the array are distinct and FALSE if otherwise.
2. Write a c++ program that takes from the user the ​number of courses​ and constructs...
2. Write a c++ program that takes from the user the ​number of courses​ and constructs 3 ​dynamic 1D arrays​ with size courses+1. Each array represents a student. Each cell in the array represents a student’s mark in a course. In the last cell of each 1D array you should calculate the average mark of that student. Then output the average mark of all students in each course. Delete any allocated memory. Example Number of courses : 4 50 60...
PYTHON Write a program that accepts a range of input from the user and checks whether...
PYTHON Write a program that accepts a range of input from the user and checks whether the input data is sorted or not. If the data series is already sorted your program should print “True” or should print “False” otherwise. You should not use any sort function for this program. Input: How many numbers you want to input: 3 # user input 3 Input the number: 5 Input the number: 2 Input the number: 7 Output: False
Need this program in python. The data must be taken from user as input. Write a...
Need this program in python. The data must be taken from user as input. Write a program that prompts the user to select either Miles-to-Kilometers or Kilometers-to-Miles, then asks the user to enter the distance they wish to convert. The conversion formula is: Miles = Kilometers X 0.6214 Kilometers = Miles / 0.6214 Write two functions that each accept a distance as an argument, one that converts from Miles-to-Kilometers and another that converts from Kilometers-to-Miles The conversion MUST be done...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT