Question

4.21 LAB: Detective Work (Python) Using a list help Dr. Pepper investigate a crime. He usually...

4.21 LAB: Detective Work (Python)

Using a list help Dr. Pepper investigate a crime. He usually asks 5 questions to each person he interviews:

  1. "Did you call the victim?"
  2. "Were you in the crime scene?"
  3. "Do you live close to the victim?"
  4. "Did you owe money to the victim?"
  5. "Have you ever worked with the victim?"

The answers are always either "Yes" or "No".

Print the list after you record all the answers.

Your program must give a final verdict about the participation of that person in the crime. If there are 2 positive answers this person must be classified as "Suspect". For 3 or 4 positive answers the classification is "Accomplice", and for 5 positive answers the classification is "Killer". Otherwise, this person should be classified as "Innocent".

For example, if the input is:

No
Yes
Yes
Yes
No

The expected output is:

The recorded answers were ['No', 'Yes', 'Yes', 'Yes', 'No']

The verdict is: Accomplice.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program Code to Copy

answers = []
##Taking answers and appending it to answers list
answers.append(input("Did you call the victim? "))
answers.append(input("Were you in the crime scene? "))
answers.append(input("Do you live close to the victim? "))
answers.append(input("Did you owe money to the victim? "))
answers.append(input("Have you ever worked with the victim? "))

print("\nThe recorded answers were ", answers)
print()

#Initiallising ansery count as zero
yesCount = 0
noCount = 0
#Traversing answer list to get positive and negative answer count
for ans in answers :

if ans == 'Yes' :
yesCount = yesCount + 1
elif ans == 'No' :
noCount = noCount + 1
  
#Displaying Verdict
#If 3 or 4 Positive answers then Accomplice
if yesCount == 3 or yesCount == 4:
print("The verdict is: Accomplice.")

#If 5 Positive answers then Killer   
elif yesCount == 5:
print("The verdict is: Killer.")

#else Innocent   
else :
print("The verdict is: Innocent.")

Program Screenshot

Program Output

Add a comment
Know the answer?
Add Answer to:
4.21 LAB: Detective Work (Python) Using a list help Dr. Pepper investigate a crime. He usually...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using a list help Dr. Pepper investigate a crime. He usually asks 5 questions to each...

    Using a list help Dr. Pepper investigate a crime. He usually asks 5 questions to each person he interviews: "Did you call the victim?" "Were you in the crime scene?" "Do you live close to the victim?" "Did you owe money to the victim?" "Have you ever worked with the victim?" The answers are always either "Yes" or "No". Print the list after you record all the answers. Your program must give a final verdict about the participation of that...

  • Article Summary I Read the article below and provide feedback by writing a 2 page summary....

    Article Summary I Read the article below and provide feedback by writing a 2 page summary. Please write in essay format (you may include the questions but the response should be in essay format) Must include the following information Title of the article Author(s) of the article Reference list (include the article itself and any other reference material such as another article that is cited in your summary). Use the reference list in the article to get information about another...

  • First, read the article on "The Delphi Method for Graduate Research." ------ Article is posted below...

    First, read the article on "The Delphi Method for Graduate Research." ------ Article is posted below Include each of the following in your answer (if applicable – explain in a paragraph) Research problem: what do you want to solve using Delphi? Sample: who will participate and why? (answer in 5 -10 sentences) Round one questionnaire: include 5 hypothetical questions you would like to ask Discuss: what are possible outcomes of the findings from your study? Hint: this is the conclusion....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT