Wednesday, June 8, 2016

Find Your Perfect Pet Using Python!

           
If you're interested in learning Python, you're probably wondering what you can do with it. It is considerably harder to do a graphic project such as a video game or animation than it is in Scratch, but there are plenty of fabulous beginner projects that you can do!
               One of these projects is a simple quiz. You can use it to study for school, or make a fun personality quiz to give to your friends. I made a quiz that predicts your 'perfect pet' based on your input! I include my code below, and you can use it as a template for your own quiz. This code does not run properly in the browser environment CodeSkulptor because of minor differences in input syntax. However, you will be able to take the quiz if you enter it into the Python launcher on your computer. If you don't have Python, you can still take the quiz manually in the version above the code. 

As you are taking this quiz manually, consider how you might implement it in Python. Try it out, and then see the code below!
 Find Your Perfect Pet: Question 1

1. Where will you most likely want to keep your pet?
A. wherever it wants to go
B. Outdoors around my neighborhood
C. In a tank in my house
D. With me always
E. In the yard and in the house
F. Wherever there are ants

2.  You would ideally like your pet to be...
A. quiet and unobtrusive
B. not be a picky eater
C. fuzzy
D. be loyal
E. scare away burglars
F. eat ants

3. Your favorite thing to do with a pet is...
A. let it be
B. take it outdoors
C. pet it
D. have a close relationship with it
E. scare other people
F. watch it eat ants 

4. How much time per day are you willing to spend with your pet?
A. Whenever my pet wants to spend time with me
B. I don't have much time to spend with my pet
C. Whenever I want to spend time with my pet
D. All the time, whether I want to or not
E. I have a lot of time to spare
F. It depends on how many ants there are

5. How willing are you to provide special food for your pet?
A. Not very
B. My pet will probably eat lots of things it finds outside
C. I understand that my pet might need special food, and I will provide it
D. I am extremely willing to give my pet whatever food it needs, even if it is inconvenient for me
E. I prefer that my pet is a vegetarian
F. I have plenty of ants

6. What would you most likely name your pet?
A. Teeny, Moe, Cici
B. Blacky, Patches, Fred
C. Fluffy, Spot, Bob
D. Fido, Shadow, Ringo
E. Buster, Bruiser, Pebbles
F. Aardy, Varky, Antie


If you entered mostly A's, your perfect pet is...
A PARAMECIUM!

If you entered mostly B's, your perfect pet is...
A BUZZARD!

If you entered mostly C's, your perfect pet is...
BREAD MOLD!

If you entered mostly D's, your perfect pet is...
A LEECH!

If you entered mostly E's, your perfect pet is...
A STEGOSAURUS!

If you entered mostly F's, your perfect pet is...
AN AARDVARK! 


<Code Starts Here>

print ('This quiz shall tell you your ideal pet! Let\'s get started.')
print('First, what is your name?')
name = input()
print(name, ',here is your first question.')
print ('Where will you most likely want to keep your pet?')
print ('a. Wherever it wants to go.')
print ('b. Outdoors around my neighborhood.')
print ('c. In a tank in my house')
print ('d. With me always')
print ('e. in the yard and in the house ')
print ('f. Wherever there are ants.')

answer1 = input()
print('You would ideally like your pet to...')
print('a. quiet and unobtrusive.')
print('b. not be a picky eater. ')
print('c. be fuzzy.')
print('d. be loyal.')
print('e. scare away burglars.')
print('f. eat ants.')
answer2 = input()
print('Your favorite thing to do with a pet is...')
print('a. let it be.')
print('b. take it outdoors')
print('c. pet it.')
print('d. to have a close relationship with it.')
print('e. to scare other people.')
print('f. watch it eat ants.')
answer3 = input()
print('How much time per day are you willing to spend with your pet? ')
print('a. Whenever my pet wants to spend time with me.')
print('b. I don\'t have much time to spend with my pet.')
print('c. Whenever I want to spend time with my pet.')
print('d. All the time, whether I want to or not.')
print('e. I have a lot of time to spare.')
print('f. It depends on how many ants there are.')
answer4 = input()
print(' How willing are you to provide special food for your pet?')
print('a. Not very.')
print('b. My pet will probably eat lots of things it finds outside.')
print('c. I understnd that my pet might need special food, and I will provide it.')
print('d. I am extremely willing to give my pet whatever food it needs, even if it is inconvenient for me.')
print('e. I prefer that my pet is a vegetarian.')
print('f. I have plenty of ants.')
answer5 = input()
print('What would you most likely name your pet?')
print('a. Teeny, Moe, Cici')
print('b. Blacky, Patches, Fred')
print('c. Fluffy, Spot, Bob')
print('d. Fido, Shadow, Ringo ')
print('e. Buster, Bruiser, Pebbles')
print('f. Aardy, Varky, Antie')
answer6 = input()
mylist=[answer1, answer2, answer3, answer4, answer5, answer6]
na =0
nb = 0
nc = 0
nd = 0
ne = 0
for i in mylist:
    if (i == 'f'):
        print(' Your perfect pet is... an AARDVARK!')
        break
    elif (i == 'a'):
        na=na+1
    elif (i == 'b'):
        nb = nb + 1
    elif (i == 'c'):
        nc = nc + 1
    elif (i == 'd'):
        nd = nd + 1
    elif (i == 'e'):
        ne = ne + 1
    elif (na == nb) or (na == nc) or (na == nd) or (na == ne) or (nb == nc) or (nb == nd) or (nb == ne) or (nc == nd) or (nc == ne) or (nd == ne):
        print('Will your pet spend more time indoors or outdoors?')
        putin = input()
        if answer == 'indoors':
            print('Your perfect pet is... either a PARAMECIUM, BREAD MOLD, or LEECH!')
        else:
            print('Your perfect pet is... either a BUZZARD, STEGOSAURUS, or AARDVARK!')
           
       
if (na > nb) and (na > nc)and (na > nd) and (na > ne):
    print('Your perfect pet is... a PARAMECIUM!')
if (nb > na) and (nb > nc) and (nb > nd) and (nb > ne):
    print('Your perfect pet is... a BUZZARD!')
if (nc > na) and (nc > nb) and (nc > nd) and (nc > ne):
    print('Your perfect pet is... BREAD MOLD!')
if (nd > na) and (nd > nb) and (nd > nc) and (nd > ne):
    print('Your perfect pet is... a LEECH!')
if (ne > na) and (ne > nb) and (ne > nc) and (ne > nd):
    print('Your perfect pet is... a STEGOSAURUS!')

   

No comments:

Post a Comment