Python.

Python Controlled Assessment Practice

score = 0
qcount= 0

import random
import operator

decisions=[10,20,30,40,50,2,3,4,5,6,7,8,9,15,25,35,45]

operators=["+","-","*"]

#ops={"+": operator.add, "-": operator.sub, "*":operator.mul}

name = (input("Please enter your name :"))

while qcount != 10:

    qcount=qcount+1
number1=random.choice(decisions)
number2=random.choice(decisions)
ops=random.choice(operators)
question=str(number1)+ops+str(number2)

    realanswer=eval(question)
#print(realanswer)

    studentanswer=int(input("Question number "+ str(qcount) + "\n" + question +"= ?"))
#print(studentanswer)

 

    if realanswer==studentanswer:
score=score+1
print("Your correct")
else:
print("Sorry your answer is incorrect")

 

print("++++++++++++++++++++++++++++++")
print("Name:",name)
print("Score:",score, " out of 10")
print("+++++++++++++++++++++++++++++++")

 

def readfile(class):

    filename=class+".txt"
channel=open(filename,"r+")
results=channel.readlines()
channel.close()
return(class)
#-------------------

def writefile(class):
line1 = raw_input("line 1: ")
line2 = raw_input("line 2: ")
line3 = raw_input("line 3: ")

    print "I'm going to write these to the file."

    filename.write(line1)
filename.write("\n")
filename.write(line2)
filename.write("\n")
filename.write(line3)
filename.write("\n")

def closefile(class):
Print "And finally, we close it."
target.close()

 

class=input("Please enter a class")
results=readfile(class)
print(results)
Pick Random number

 

 

Teaching Ideas.
Agbonline Teaching Exercises.
Using python.com
20 code Challenges( complete for GCSE 9-1 )
Python Exercises.
Introduction to Python
Python exercises