Presentation is loading. Please wait.

Presentation is loading. Please wait.

Create Your Own Quiz using_Python KS3 COMPUTING KS3 Computing

Similar presentations


Presentation on theme: "Create Your Own Quiz using_Python KS3 COMPUTING KS3 Computing"— Presentation transcript:

1 Create Your Own Quiz using_Python KS3 COMPUTING KS3 Computing
A Python Quiz

2 You are going to create a quiz on a topic of your own choice
Introduction You are going to create a quiz on a topic of your own choice The topic is your choice as long as it is sensible Example topics include: A school subject General knowledge A hobby or interest

3 You will use the players name to personalise the quiz.
Quiz Features Main quiz features Name You will use the players name to personalise the quiz. Minimum 3 Questions The quiz will have a minimum of 3 Questions. The quiz should be challenging, make it difficult! Output the Score Not only will your quiz tell the player their final score at the end, it will tell them their score after each question. Save Score to a File Every time your quiz is taken it will save the name and score of the person into a file.

4 How much progress am I making?
Success Criteria How much progress am I making? All Students Created a quiz with at least three questions. Quiz runs with minor errors. P1 - P3 Most Students Created a quiz containing at least three questions using features such as various question types, elif statements and variable scores. Quiz runs with no errors. P4 - P6 Some Students Created a quiz containing at least five questions using features such as various question types, elif statements and variable scores. Saves data to a file. Quiz runs with no errors. P7 - P9 Your quiz should be unique and creative to get into the upper parts of each band. Copying and pasting will have a negative effect on your P score.

5 Identifying and Fixing Errors
Troubleshooting Identifying and Fixing Errors 1 Find the error yourself by following the steps below. 2 Ask the people sat either side of you to help you spot the error. 3 Ask the teacher only if you have tried everything else. Brackets & Speech Marks There should always been an even number (0, 2, 4, 6..) of both of these in each line. Data Types Make sure when a number is your answer you are using int, and not using it when you are using a word. Indents All lines under if/elif/else statements needed to indented four spaces using the tab key (above caps lock).

6 What Am I looking For? Questions Error-free Independently Features
Assessment Criteria Questions How many questions you have produced? Error-free Is it error free? Independently Have you worked independently? Features What features of Python have you used? Creativity Have you work used your creativity and imagination?

7 Quiz Title Decide on an interesting title for your quiz to be displayed as soon as the program is run Start a new Python file Pick a title for your quiz import time print(“ ”) print(“-----Mr Lyon’s Computer Game Quiz!-----”) Run your quiz by pressing F5 and save it as My Python Quiz

8 Ask the quiz player their name
Player Name Ask the quiz player their name time.sleep(1) name = input(“What is your name? ”) time.sleep(1) pauses the game for one second, you can change this value.

9 Set a starting score and tell the player it
Player Score Set a starting score and tell the player it time.sleep(1) score = 0 #you can chose your own starting score

10 Answer that is a word or sentence
Question Example Answer that is a word or sentence WORD print(“Question 1!”) #change this to the correct question number time.sleep(1) answer = input(“What is the name of the arcade game released in 1978 based in space? “) #make sure there is a space after the question mark if answer.lower() == “space invaders”: #no capital letters print(“Correct!”) score = score + 1 #you can change this value print(name + “, your new score is “ + str(score) + “.”) else: print(“Wrong!”) print(name + “, your score is still “ + str(score) + “.”)

11 Question Example Answer that is a number NUMBER print(“Question 1!”)
time.sleep(1) answer = int(input(“What year was Pacman released in? “)) #don’t forget second bracket if answer == 1985: #make sure there are no quotes around a number print(“Correct!”) score = score + 1 print(name + “, your new score is “ + str(score) + “.”) else: print(“Wrong!”) score = score – 1 #this is how you minus points print(name + “, your score is still “ + str(score) + “.”)

12 MULTI-ANSWER (Same score each answer)
Question Example Question with more than one possible answer MULTI-ANSWER (Same score each answer) print(“Question 1!”) time.sleep(1) answer = input(“Name one supporting character from the Sonic series? “) if answer.lower() in [“tails”, “knuckles”]: #no capital letters print(“Correct!”) score = score + 1 print(name + “, your new score is “ + str(score) + “.”) else: print(“Wrong!”) print(name + “, your score is still “ + str(score) + “.”)

13 MULTI-ANSWER (Different score each answer)
Question Example Different answers have different points MULTI-ANSWER (Different score each answer) print(“Question 1!”) time.sleep(1) answer = input(“Name one supporting character from the Sonic series? “) if answer.lower() == “tails”: #no capital letters print(“Correct!”) score = score + 10 print(name + “, your new score is “ + str(score) + “.”) elif answer.lower() == “knuckles”: score = score + 5 else: print(“Wrong!”) print(name + “, your score is still “ + str(score) + “.”)

14 Questions You need to have a minimum of 3 questions.
Make sure you have 3 questions before going on to the next slide.

15 Tell the player their final score
Output the Final Score Tell the player their final score Insert this code after your last question #prints the final score to the screen print(name + “, your final score is: “ + str(score) + “.”)

16 Save the player name and score to a text file
Saving Scores part 1 Save the player name and score to a text file Insert the code below the title but before the player enters their name def saveScore(n,s): #opens the file or creates one if it does not already exist file = open(“scores.txt”, “a”) #records the user’s score in the file file.write(“Name: “ + n + ”, Score: “ + str(s) + ”\n”) #closes the file file.close() return You need part 2 on the next slide

17 Insert the code below at the very end of your program
Saving Scores part 2 Insert the code below at the very end of your program #calls the saveScore function and passes the name and score variables saveScore(name,score) Next time you run the quiz, your score will be saved in a file (in the same folder as where your Python quiz is saved). Your quiz is finished!

18 The more questions you have the higher mark you will get.
Keep adding them! The more questions you have the higher mark you will get.


Download ppt "Create Your Own Quiz using_Python KS3 COMPUTING KS3 Computing"

Similar presentations


Ads by Google