Certainly!
import random import json import os
def Alpha():
Name = str(input("Enter Your Name. "))
Class = str(input("Enter Your Class. "))
print ("Hello " + Name + " of " + Class + ".")
Symbols = ["+" , "-" , "*"]
Count = 1
Score = 0
while Count < 11:
print ("\nQuestion: " + str(Count))
N1 = str(random.randrange(12))
N2 = str(random.randrange(12))
S1 = str(random.choice(Symbols))
Answer = eval(N1 + S1 + N2)
try:
if int(input(N1 + S1 + N2 + " = ")) == int(Answer):
print ("Correct.")
Score += 1
Count += 1
else:
print ("Incorrect. \n\nAnswer: " + str(Answer))
Count += 1
except:
print ("Invalid. \n\nAnswer: " + str(Answer))
Count += 1
print ("\nScore: " + str(Score))
with open(str(Class) + '.txt', 'a') as File:
if os.stat(str(Class) + '.txt').st_size == 0:
Data = [(Score,Name)]
File.write(str(Data))
else:
Extract = eval(open(str(Class) + '.txt', 'r').read())
Extract.append((Score,Name))
open(str(Class) + '.txt', 'w').write(str(Extract))
def Beta():
Name = str(input("Whose record would you like to see? "))
Class = str(input("What class are they in? "))
Extract = eval(open(str(Class) + '.txt', 'r').read())
if [i for i, v in enumerate(Extract) if v[1] == Name]:
#Here
else:
print("No person with that name has taken the test.")
open(str(Class) + '.txt', 'w').write(str(Extract))