samedi 21 décembre 2019

How can i randomize a list of questions in python 3.8?

def get_questions():
    # Notice how the data is stored as a list of lists
    return [
            ["What color is the daytime sky on a clear day? ", "blue"],
            ["What is the answer to life, the universe, and everything? ", "42"],
            ["What is a three letter word for a mouse trap? ", "cat"],
            ["Who portrayed Edward Scissorhands? ", "Johnny Depp"],
            ["What are made and repaired by a cobbler? ", "shoes"],
            ["Apart from womanizing and producing films, what was the other passion of Howard Hughes? ", "aviation"],
            ["How many states make up The United States of America? ", "50"],
            ["H20 is the chemical formula for what? ", "water"],
            ["Complete the title of the play by Shakespeare - 'The Merchant of ? ", "Venice"],
            ["Brie and Camembert are types of what food? ", "cheese"],
            ["What type of creature lives in an aviary? ", "bird"],
            ["How many players make a Rugby Union team? ", "15"],
            ["What decade Did Elizabeth become Queen? ", "1950's"],
            ["The phrase '3 strikes and you are out' is in what sport? ", "baseball"],
            ["In which sport can a player score a 'Birdie,' 'Eagle,' 'Albatross'? ", "golf"],
            ["How many English monarchs have been named 'Edward'? ", "8"],
            ["Where is the Great Barrier Reef? ", "Australia"],
            ["Which English county is known as 'Shakespeare's County'? ", "Warwickshire"],
            ["A pug is a breed of what animal? ", "dog"],
            ["How many colors are in a calico cat? ", "3"]]

This is part of my python code I'm attempting to make into a quiz. I have tried to use the random.shuffle(get_questions) code after the questions, but it doesn't work. I'd like to know what else i can do to make this produce random questions each time it's run.




Aucun commentaire:

Enregistrer un commentaire