Python.
Simple Graphical User Interface Quiz
import easygui
# SETTING THINGS UP (only need this once)
easygui.msgbox("Welcome to my awesome quiz!")
score = 0
# QUESTION 1
answers = ["A House","A Car","Superman","A Plane"]
choice = easygui.buttonbox("What is this?","Quiz!",answers,"house.gif")
if choice == "A House":
easygui.msgbox("Well done!","Quiz!")
score = score + 1
else:
easygui.msgbox("No, silly. It was a house!","Quiz!")
# MORE QUESTIONS GO HERE
choice = easygui.buttonbox("What is this?","Quiz!",answers,"car.gif")
if choice == "A Car":
easygui.msgbox("Well done!","Quiz!")
score = score + 1
else:
easygui.msgbox("No, silly. It was a car!","Quiz!")
choice = easygui.buttonbox("What is this?","Quiz!",answers,"superman.gif")
if choice == "Superman":
easygui.msgbox("Well done!","Quiz!")
score = score + 1
else:
easygui.msgbox("No, silly. It was a superman!","Quiz!")
choice = easygui.buttonbox("What is this?","Quiz!",answers,"plane.gif")
if choice == "A Plane":
easygui.msgbox("Well done!","Quiz!")
score = score + 1
else:
easygui.msgbox("No, silly. It was a plane!","Quiz!")
# END
easygui.msgbox("Well done, you scored " + str(score))
Penguin Quiz Graphical User Interface Python.
import easygui
# SETTING THINGS UP (only need this once)
easygui.msgbox("Welcome to my awesome quiz!")
score = 0
# QUESTION 1
answers = ["A King Penguin","An Adelie Penguin","A Rockhopper Penguin","A Gentoo Penguin","A Magellanic Penguin"]
choice = easygui.buttonbox("What is this?","Quiz!",answers,"kingpenguin.gif")
if choice == "A King Penguin":
easygui.msgbox("Well done!","Quiz!")
score = score + 1
else:
easygui.msgbox("No, silly. It was a King Penguin!","Quiz!")
# MORE QUESTIONS GO HERE
choice = easygui.buttonbox("What is this?","Quiz!",answers,"adeliepenguin.gif")
if choice == "An Adelie Penguin":
easygui.msgbox("Well done!","Quiz!")
score = score + 1
else:
easygui.msgbox("No, silly. It was an Adelie Penguin!","Quiz!")
choice = easygui.buttonbox("What is this?","Quiz!",answers,"rockhopperpenguin.gif")
if choice == "A Rockhopper Penguin":
easygui.msgbox("Well done!","Quiz!")
score = score + 1
else:
easygui.msgbox("No, silly. It was a Rockhopper Penguin!","Quiz!")
choice = easygui.buttonbox("What is this?","Quiz!",answers,"gentoopenguin.gif")
if choice == "A Gentoo Penguin":
easygui.msgbox("Well done!","Quiz!")
score = score + 1
else:
easygui.msgbox("No, silly. It was a Gentoo Penguin!","Quiz!")
choice = easygui.buttonbox("What is this?","Quiz!",answers,"magellanicpenguin.gif")
if choice == "A Magellanic Penguin":
easygui.msgbox("Well done!","Quiz!")
score = score + 1
else:
easygui.msgbox("No, silly. It was a Magellanic Penguin!","Quiz!")
# END
easygui.msgbox("Well done, you scored " + str(score))
Easy Gui Guess my Number
import random
import time
import easygui
#truncate and rounds down
num=int(random.random()*100)+1
guess=0
count=0
#print number
print(num)
#wait 2 seconds
time.sleep(.2)
print("/n"* 20)
while num !=guess:
guess = int(easygui.integerbox("Guess my number(1 to 100)"))
count +=1
if guess>num:
easygui.msgbox(guess, "This number is too high.")
else:
if guess<num:
easygui.msgbox(guess, "This number is too low.")
easygui.msgbox(num,"Well Done! That's correct")
easygui.msgbox(count,"The number of guess's was:")
Teaching Ideas.
Agbonline Teaching Exercises.
Using python.com
20 code Challenges( complete for GCSE 9-1 )
Python Exercises.
Introduction to Python
Python exercises