Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- score = 0
- print("Welcome to the quiz!")
- time.sleep(1)
- print("In order to play, you have to register an account.")
- time.sleep(1)
- name = str(input("Please enter your full name: "))
- time.sleep(1) # Validates password
- for 8 characters long.
- while True:
- password = input("Please enter your account password(at least 8 characters): ")
- if len(password) < 8:
- print("Make sure your password is at least 8 letters.")
- else :
- print("Password is fine.")
- break
- # Age validation for 11 and over only
- age = int(input("Please enter your age: "))
- if (age < 11):
- print("You have to be 11 or over to play the quiz.")
- exit()
- else :
- print("Your age is fine.")
- YGrp = int(input("What year group are you in?(number only): "))
- # Creates a username using first 3 letters of the full name and the user 's age.
- username = name[: 3] + str(age)
- filename = username + ".txt" # Details are stored in an external text file; Username, password, age and year group.
- file = open(filename, 'w')
- file.write("Username: " + username)
- file.write("nPassword: " + password)
- file.write("nAge: " + str(age))
- file.write("nYear Group: " + str(YGrp))
- file.close()
- # Easy questions in an external file
- file = open("easyquestions.txt", 'w')
- file.write("What does CPU stand for?")
- file.write("na. Central Processor Unit")
- file.write("nb. Central Processing Unit")
- file.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement