Happy New Year! Here’s a program…

Leading up to the momentus 2017/2018 new years ding, we couldn’t decide how to choose 10 of 50 questions in a Pub Quiz game that we picked to play. I decided to make a program to do just this, and randomise the questions. Here’s my new years python gift, to you. Have a good one!

from random import randrange

def main():
    numrange = [1, 51]
    while True:
        i = input()
        if i == "q":
            break
        else:
            questions(numrange)
    return 1

def questions(numr):
    questions = []
    for i in range(10):
        while True:
            tmp = randrange(numr[0], numr[1])
            if tmp not in questions:
                questions.append(tmp)
                break

    questions = sorted(questions)
    for i in questions:
        print(str(i))
        
    return 1

if __name__ == "__main__":
    main()

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.