Conditionals Quiz

Conditionals Quiz

This quiz is intended to test your knowledge of the concepts introduced in Conditional Statements in Ren’Py and A Quick Primer on Variables in Ren’Py. Explanations are provided for each answer, and you can take the quiz as many times as you like.

It’s okay if you don’t know the answers to every quiz question, even after going through the tutorials. Some quiz questions are there to point out common errors or mistakes and teach you how to identify and fix them. If you don’t understand a question, feel free to skip it and read the explanation after submitting the quiz. There’s a free question box at the end of the quiz if you have any comments, questions, or feedback.


Question 1

What will the last line display to the user?

default count = 0
default went_to_park = True
default owns_dog = True
default stayed_at_home = False
label start():

    if went_to_park:
        $ count += 1
        "You went to the park."
    if owns_dog:
        $ count += 1
        "You took your dog out for a walk."
    if stayed_at_home:
        $ count += 1
        "You stayed at home."
    "The value of count is [count]."
    return

Tip: $ count += 1 will increase the value of count by 1 each time it is run. So, if count starts at 0 and one $ count += 1 line runs, count will be equal to 1 at the end. If two $ count += 1 lines run, it will be equal to 2 by the end.

 
 
 
 
 

Question 2

What will the last line display to the user?

default count = 0
default went_to_park = True
default owns_dog = True
label start():

    if went_to_park:
        $ count += 1
        "You went to the park."
    elif owns_dog:
        $ count += 1
        "You took your dog out for a walk."
    else:
        $ count += 1
        "You stayed at home."
    "The value of count is [count]."
    return

Note: Yes this is different from the last question.

 
 
 
 
 

Question 3

How many conditional statements are there in the following code?

default talked_to_xia = False
default shopping_with_ash = False
default bought_zoran_milkshake = False
label start():

    if talked_to_xia:
        "Xia looked over at you, clearly worried about how you were taking the news."
    if shopping_with_ash:
        "Ash was trying to catch your eye, and they smiled when you made eye contact."
    if bought_zoran_milkshake:
        "Zoran, beside you, offered his milkshake."
    else:
        "No one seemed to realize how this news was affecting you."
        "You felt very alone."
 
 
 
 

Question 4

Consider the following situation:

If the player has mentioned they like roller coasters, they should point it out to their date. If they like scary things but not roller coasters, they will point out the haunted house instead. However, if they’re eating cotton candy at the time, they should point out a photo opportunity instead of mentioning either the roller coaster or haunted house (since they can’t go on rides while eating).

The following code is intended to represent the above scenario:

label start():
    # Variables are set up here with their values below!
    if likes_roller_coasters:
        "You" "We should try the roller coaster!"
        jump ride_roller_coaster
    elif likes_scary_things:
        "You" "We should try the haunted house!"
        jump haunted_house
    elif eating_cotton_candy:
        "You" "Let's go over there and take a picture!"
        jump eating_candy
    return

What combination(s) of variables might cause an unintended result?

 
 
 
 
 
 
 
 
 

(Optional) Do you have any feedback on the lesson or the quiz?


Question 1 of 5


If you’d like to know more about the content covered in this quiz, see Conditional Statements in Ren’Py and A Quick Primer on Variables in Ren’Py. If you’re ready to move on to new content, check out Simple Variable Types in Ren’Py.

This Post Has 2 Comments

  1. Kyle

    Question 4 says:
    “If the player has mentioned they like roller coasters, they should point it out to their date. If they like scary things, they will point out the haunted house instead.”

    I take that to mean that even if they like roller coasters, if they like scary things, they will point that out instead of roller coasters.

    So, answer 4: “likes_roller_coasters = True, likes_scary_things = True, eating_cotton_candy = False”

    Perhaps the question should be reworded as:
    “”If the player has mentioned they like roller coasters, they should point it out to their date. If they don’t like roller coasters, but they like scary things, they will point out the haunted house instead.”

    1. Fen

      Good point! I appreciate you bringing that up. I’ve modified the wording to make the intended logic clearer.

Leave a Reply