Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- userFile=open("user.txt","a+")
- userFile.write("welcome to the amazing quiz ")
- close="no"
- while close != "yes":
- #this is the login code
- name =input("create a username: ")
- password =input("create a password: ")
- print("Thank you, you have now created a username and password.")
- command = None
- input1 = None
- input2= None
- while input1 !=name:
- input1 = input("enter your username to access the quiz: ")
- while input2 !=password:
- input2 = input("enter your password please to access the quiz: ")
- print("welcome to your quiz!")
- if name == name:
- print("Thank you, you will now be entered into the quiz")
- #this saves in to the text file userFile
- userFile.write(input("what is your first name? " ))
- userFile.write(input("what is your surname? " ))
- userFile.write(input("what is your age? " ))
- userFile.write(input("what is your year group? " ))
- userFile.write(input("what is your username? The username is made up from the first 3 letters of Their name and their age" ))
- #the difficulty the user wants
- difficulty=int(input(("What difficulty would you like to do the topic on 1=easy 2=medium 3=hard:")))
- if difficulty==1:
- print("So you want to do a quiz on easy")
- elif difficulty==2:
- print("So you want to do a quiz on medium")
- elif difficulty==3:
- print ("So you want to have a quiz on hard")
- else:
- print ("Not from selection")
- #users choice of quiz
- user_subject=int(input(("Which quiz would you like to do 1=maths 2=computer science: ")))
- if user_subject==1:
- print("This is the quiz for maths")
- import questionsmaths
- print("You scored",score,"/5 well done")
- if score==1:
- print("You got 1 out of 5, that is a grade 1")
- elif score==2:
- print("You got 2 out of 5, thats a grade 2")
- elif score==3:
- print("You got 3 out of 5, you got a grade 3")
- elif score==4:
- print("You got 4 out of 5, thats a grade 4")
- elif score==5:
- print("You got 5 out of 5, thats a grade 9")
- close=input("Please type yes to exit the quiz\n")
- #computer science quiz questions
- elif user_subject==2:
- print("This is the quiz for computer science")
- score=0
- import questionscomputerscience
- if score==1:
- print("You got 1 out of 5, that is a grade 1")
- elif score==2:
- print("You got 2 out of 5, thats a grade 2")
- elif score==3:
- print("You got 3 out of 5, you got a grade 3")
- elif score==4:
- print("You got 4 out of 5, thats a grade 4")
- elif score==5:
- print("You got 5 out of 5, thats a grade 9")
- userFile.close()
- close=input("Thank you for taking part in the quiz,now Please type yes to exit the quiz\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement