Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (6 votes)
6K views

Python Personality Quiz

The document provides instructions for creating a Python personality quiz that asks the user multiple choice questions and tracks their answers to determine if they selected mostly As, Bs, or Cs. Based on their highest count, it will output a corresponding result (e.g. "You're Harry Potter!"). It includes steps to initialize counters, ask questions, increment counters based on answers, repeat for all questions, then determine the highest counter to output the result. It also suggests extensions like adding more options/results, using a dictionary instead of variables, and creating a reusable function.

Uploaded by

Kelly Lougheed
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (6 votes)
6K views

Python Personality Quiz

The document provides instructions for creating a Python personality quiz that asks the user multiple choice questions and tracks their answers to determine if they selected mostly As, Bs, or Cs. Based on their highest count, it will output a corresponding result (e.g. "You're Harry Potter!"). It includes steps to initialize counters, ask questions, increment counters based on answers, repeat for all questions, then determine the highest counter to output the result. It also suggests extensions like adding more options/results, using a dictionary instead of variables, and creating a reusable function.

Uploaded by

Kelly Lougheed
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Python Personality Quiz

You will make a personality quiz that will give the user a result based on if they picked mostly
A’s, mostly B’s, or mostly C’s!

After you’ve planned out your quiz (you must have at least three questions and three answers),
dive into the code:

1. Create variables to store the number of A answers, B answers, and C answers.

a_count = 0
b_count = 0
c_count = 0

2. Have the program ask a question and get an answer from the user.

q1_answer = input("How would you describe yourself? a)


brave, b) loyal, or c) smart?")

3. Based on the user’s answer, have the program increment either a_count, b_count, or
c_count.

if q1_answer.lower() == 'a':
a_count += 1
elif q1_answer.lower() == 'b':
b_count += 1
elif q1_answer.lower() == 'c':
c_count +=1
else:
print("Sorry, I don't understand that response.")

4. Repeat steps 2-3 for each question.

5. Calculate which of a_count, b_count, or c_count is highest, and give the user the results.

if a_count > b_count and a_count > c_count:


print("You're Harry Potter!")
elif b_count > a_count and b_count > c_count:
print("You're Ron Weasley! ")
elif c_count > a_count and c_count > b_count:
print("You're Hermione Granger! ")
else:
print("Wow, you're a combination of all three: Harry,
Ron, and Hermione! ")

Extensions

1. Add more options and results to your quiz. Give an explanation for each result.

2. Use a dictionary to keep track of a, b, and c counts. Then loop through the dictionary to
find the variable with the highest count at the end.

3. Use a function that takes in a parameter of the user’s answer and allows you to reuse
the code in step #3.

You might also like