mercredi 7 décembre 2016

Python, Asking Questions without repeats

#TODO: QUESTION 1
    num = random.randint(1, 100)
    print(num)
    # Male or Female probabilities = 35%
    if num > 0 and num <= 18:
        femaleCheck(People)
        printPeopleList(People)
    if num > 18 and num <= 35:
        maleCheck(People)
        printPeopleList(People)
    # Wearing a T-Shirt probabilities = 15%
    if num > 35 and num <= 50:
        tShirtCheck(People)
        printPeopleList(People)
    #Eye Color probabilities 25%
    if num > 50 and num <= 63:
        eyeColorBrownCheck(People)
        printPeopleList(People)
    if num > 63 and num <= 75:
        eyeColorBlueCheck(People)
        printPeopleList(People)
    #Showing Teeth probabilities 25%
    if num > 75 and num <= 100:
        showingTeethCheck(People)
        printPeopleList(People)

Here is a small portion of the code for a guess who game that I creating. As it is currently implemented it chooses a random number from a list and asks the corresponding number to carry out a function. Once question 1 is asked I would like it to ask Question 2 out of the remaining available options. Question 3 will include the remaining 2 options, and also introduce a new function to ask. I am struggling to figure out which method would be most efficient; I know that I could just indent each question following, but that would be terribly messy and hard to read. Is there some method I could use to make the following questions asked in a simplistic manner? Potentially removing that range from random integer?

Aucun commentaire:

Enregistrer un commentaire