Quiz game

Description:

This application creates a quiz game. The user should answer to 10 questions
picking one of the 3 different choices. At the end the scoure and the elapsed time have to be shown.

# python solution for mobile programming lecture, module A
# by Yuanye Wang, Carlos Flores Mayorga and Yuqing Zhang
#
# Aalborg University
# 10-10-2006
import appuifw
import e32
import time
import os
import audio
import graphics
a=time.time()
def function_Start():
Que1 = ur'13+4='
Que2 = ur'13-4='
Que3 = ur'13*4='
Que4 = ur'13/4='
Que5 = ur'13%4='
Que6 = ur'The capital of Danmark is:'
Que7 = ur'Who won the worldcup?'
Que8 = ur'Which one appears erlier?'
Que9 = ur'Which one is different?'
Que10 = ur'Which one is Danish?'
Ques = [Que1,Que2,Que3,Que4,Que5,Que6,Que7,Que8,Que9,Que10]
#
An1 = [u'17',u'16',u'18']
An2 = [u'10',u'9',u'21']
An3 = [u'5',u'62',u'52']
An4 = [u'4',u'3',u'1']
An5 = [u'4',u'3',u'1']
An6 = [u'Copenhagen',u'Aarhus',u'Aalborg']
An7 = [u'France',u'Italy',u'Sweden']
An8 = [u'C',u'Python',u'Java']
An9 = [u'dog',u'cat',u'stone']
An10 = [u'Andersen',u'the Green brothers',u'Edison']
Ans = [An1,An2,An3,An4,An5,An6,An7,An8,An9,An10]
rightans = [0, 1, 2, 1, 2, 0, 0, 0, 2, 0]
#
index=range(0,10)
score=0
for k in range(0,10):
index[k] = appuifw.popup_menu(Ans[k],Ques[k])
print index[k]
if index[k]==rightans[k]:
score+=1
print u'Good'
else:
print u'try again'
msg = u'your score is %d' %score
appuifw.note(msg,'info')
b=time.time()
msg2 = u'the elapsed time is: %d' %(b-a)
appuifw.note(msg2,'info')
def function_Quit():
appuifw.note(u'Will quit now','info')
appuifw.app.set_exit()
appuifw.app.menu=[(u'Start query',function_Start),(u'Quit',function_Quit)]
def exit_key_handler():
app_lock.signal()
app_lock = e32.Ao_lock()
appuifw.app.exit_key_handler=exit_key_handler
app_lock.wait()

Download:

quiz.py

Output:

The following screenshots are the outcome. Just click on the icons to enlarge them for a better view.

Output

Department of Electronic Systems | Aalborg University | Niels Jernes Vej 12 | DK-9220 Aalborg | Denmark
Phone: (+45) 9635 8695 | Fax (+45) 9815 1583 | E-mail ies(at)ies.aau.dk
Copyright © 2006 Department of Electronic Systems

Last update:20-10-2006