samedi 23 mars 2019

if statement / input #'s

-I was given the following homework assignment: setting up mini-powerball and I've inserted the following pseudocode below.

-I'm still a beginner, at best, and for some reason I've hit a wall with this code!

-The part I'm struggling with the most at the moment is "if first num is between 1 and 9" which I think translates to if (my variable) == random.randit(1,9) ?

-thank you for any help you can provide

repeat until they no longer want to play

# ask the user to enter 3 numbers
    # make a variable to keep track of the numbers (a list)

    # enter first num
        # repeat until they enter a valid first number
            # input for first num
            # if first num is between 1 and 9
                # add it to the list we made earlier
                # break the loop
            # otherwsie
                # tell them it's invalid

    # enter second num
        # repeat until they enter a valid second number
            # input for second num
            # if second num is between 1 and 9
                # if second num is not in the list
                    # add it to the list
                    # break the loop
                # otherwise
                    # you have already entered this number
            # otherwise
                # tell them it's invalid

    # enter third num
        # repeat until they enter a valid third number
            # input for third num
            # if third num is between 1 and 9
                # if third num is not in the list
                    # add it to the list
                    # break the loop
                # otherwise
                    # you have already entered this number
            # otherwise
                # tell them it's invalid


# generate the draw
    # make a variable to keep track of the draw (a list)

    # randomly generate first num
        # generate int from 1 to 9
        # add it to the draw list we made earlier

    # randomly generate second num
        # repeat until we have a unique random number
            # generate int from 1 to 9
            # if NOT generated number already in list
                # add it to the draw list we made earlier
                # break the loop

    # randomly generate third num
        # repeat until we have a unique random number
            # generate int from 1 to 9
            # if NOT generated number already in list
                # add it to the draw list we made earlier
                # break the loop

# check the entered nums vs the draw
    # keep track of how many numbers we've matched (starts at 0)
    # for each of the numbers we input
        # if it's in the draw
            # add one to the matched

    # if matched 1 number
        # print the winnings
    # elif matched 2 numbers:
        # print the winnings

# ask if they want to play again
    # input

Aucun commentaire:

Enregistrer un commentaire