Max OConnell
Max OConnell
Analysis
Try and create 3 or more key success criteria for your program.
Success Criteria:
1.Allows a player to enter their details, which are then authenticated to ensure that they are
an authorised player.
a. Input from user
b. Check whether users login details are correct
c. Compare data in the CSV file
2.Stores a list of song names and artists in an external file.
a. Store song name in CSV file
b. Store artist name in CSV file
3. Selects a song from the file, displaying the artist and the first letter of each word of the
song title.
a. Select song and artist from CSV file
b. Display song and artist
4. Allows the user up to two chances to guess the name of the song, stopping the game if
they guess a song incorrectly on the second chance.
a. Allow user to guess
b. Allow 2 chances
c. Stop game if 2 incorrect answers
Design
You may like to create a flow charts which will show broadly how your program will work. If so
include your flow chart in this section.
You must create pseudocode for a part of your program (minimum of 15 lines). If possible, try
to create all of your program in pseudocode. Use the OCR guide in the specification to help
you.
import csv
FUNCTION intro():
OUTPUT "Welcome to the Game"
start=input("1)Sign in 2)Create Login")
IF start = "1":
sign_in()
ENDIF
IF start = "2":
Centre Name: Centre Number:
create_login()
ENDIF
ENDFUNCTION
FUNCTION sign_in():
datafile=open("login.csv","r")
logins=[]
for line in datafile:
linedata=line.split(",")
logins.append(linedata)
linedata[1]=linedata[1].strip()
ENDFOR
user <- input("Enter Username\n")
for item in logins:
IF user = item[0]:
OUTPUT "Username Accepted"
ENDIF
ENDFOR
password=input("Enter Password\n")
count=0
check=False
while count < 2 AND check==False:
count=count+1
for item in logins:
IF user = item[0] AND password = item[1] :
OUTPUT "Welcome!"
check <- True
break
ENDIF
ELSE:
OUTPUT "User AND pass not in the data base"
password=input("Re-enter password")
ENDFUNCTION
ENDWHILE
ENDFOR
FUNCTION create_login():
username=input("Enter your new user name:")
datafile=open("login.csv","r")
logins=[]
for line in datafile:
linedata=line.split(",")
logins.append(linedata)
linedata[1]=linedata[1].strip()
ENDFOR
OUTPUT logins
for details in logins:
IF username==details[0]:
OUTPUT "Username taken try again"
create_logins()
ELSE:
OUTPUT "Username accepted"
Centre Name: Centre Number:
break
ENDIF
ENDFOR
password=input("Enter password:")
password2=input("Re-enter password:")
IF password = password2:
OUTPUT "details successfully stored"
with open("login.csv","a", newline="")as csvfile:
writer=csv.writer(csvfile)
writer.writerow([username, password])
ENDIF
ENDFUNCTION
intro()
import csv
import random
user_scores=[]
with open("Song_list.csv")as csvfile:
songs <- list(csv.reader(csvfile))
username =input("Enter username")
FUNCTION game():
global username
songs <- list(csv.reader(open("Song_list.csv")))
user_scores <- []
ENDFUNCTION
count=0
score=0
while count < 10:
r= random.choice(songs)
points <- 3
OUTPUT r[2]
user=input("Enter Guess")
IF user.lower() = r[1]. lower():
OUTPUT "Correct"
score+=1
count+=1
user_scores.append([username, score])
OUTPUT username, "your final score is:", score
with open('Scores.csv','w', newline='')as file:
writer <- csv.writer(file)
for row in user_scores:
writer.writerow(row)
ENDIF
ENDWHILE
ENDFOR
import csv
username="max"
score=10
user_scores=[
["Msx", 10],
["b", 20],
Centre Name: Centre Number:
]
Centre Name: Centre Number:
Test design
Think of tests that you can carry out to see if your system works
If you wish to, you may add more tests to the table.
My tests:
Test What am I testing? What data will I use? Normal/Boundary/Erroneous? Expected Result
1 Login function Username=max Normal Allow user to log in
Password=max
2 Login Function Username= “!”£$$ Erroneous Don’t allow user to log in
Password=:~{>?@
3 Test whether song is Press enter Normal L________
displayed
4 Test user input for Lamborghini Normal Song is correct
song guess
Add 1 point
5 Test user input for £”$^%£^$ Erroneous Song is incorrect
song guess
-1 from song guesses
Candidate Name:
Candidate Number:
Date:
Version 1 5 © OCR 2018
Centre Name: Centre Number:
Development
Copy and paste your code into this section
Remember to try and add comments to your code to make it more readable!
My program code:
import csv
def intro():
if start == "1":
sign_in()
if start == "2":
create_login()
def sign_in():
datafile=open("login.csv","r")
logins=[]
linedata=line.split(",")
logins.append(linedata)
linedata[1]=linedata[1].strip()
Candidate Name:
Candidate Number:
Date:
Version 1 6 © OCR 2018
Centre Name: Centre Number:
if user == item[0]:
print("Username Accepted")
password=input("Enter Password\n")
count=0
check=False
count=count+1
print("Welcome!")
check = True
break
else:
password=input("Re-enter password")
Candidate Name:
Candidate Number:
Date:
Version 1 7 © OCR 2018
Centre Name: Centre Number:
def create_login():
datafile=open("login.csv","r")
logins=[]
linedata=line.split(",")
logins.append(linedata)
linedata[1]=linedata[1].strip()
print(logins)
if username==details[0]:
create_logins()
else:
print("Username accepted")
break
password=input("Enter password:")
password2=input("Re-enter password:")
if password == password2:
Candidate Name:
Candidate Number:
Date:
Version 1 8 © OCR 2018
Centre Name: Centre Number:
writer=csv.writer(csvfile)
writer.writerow([username, password])
intro()
import csv
import random
user_scores=[]
songs = list(csv.reader(csvfile))
def game():
global username
songs = list(csv.reader(open("Song_list.csv")))
user_scores = []
count=0
Candidate Name:
Candidate Number:
Date:
Version 1 9 © OCR 2018
Centre Name: Centre Number:
score=0
r= random.choice(songs)
points = 3
print(r[2])
user=input("Enter Guess")
print("Correct")
score+=1
count+=1
user_scores.append([username, score])
writer = csv.writer(file)
writer.writerow(row)
import csv
username="max"
score=10
user_scores=[
["Msx", 10],
["b", 20],
Candidate Name:
Candidate Number:
Date:
Version 1 10 © OCR 2018
Centre Name: Centre Number:
Candidate Name:
Candidate Number:
Date:
Version 1 11 © OCR 2018
Centre Name: Centre Number:
Testing
Show you have completed the tests you thought of
My tests:
My test screenshots:
Candidate Name:
Candidate Number:
Date:
Version 1 12 © OCR 2018
Centre Name: Centre Number:
Candidate Name:
Candidate Number:
Date:
Version 1 13 © OCR 2018
Centre Name: Centre Number:
Evaluation
Evaluate how successful your program was. You should like your evaluation to your testing
results.
My program was fairly successful, the game worked and I created a CSV file which included a
song name, artist and the shown song name with missing letters. My code allowed me to
search the CSV file in order for these to be outputted. I did not manage to create a
leaderboard in which the scores were saved in and I did not manage to create a piece of code
limiting the amount of guesses hence making the code endless. My login functions were
successful as you have to either create a new username and password, or enter one from the
CSV file. If you do not enter a correct username or password it will not let you log in which
means it is successful. I am proud of my coding skills and this program however I could have
made this code more successful and accurate
I developed how to do functions accurately, also I further enhanced my loops and condition
statements. I used a global username. I learnt how to use CSV files in creating a username
and password database as well as creating the song quiz in excel files. I improved my
problem solving skills in overcoming any difficulties I encountered.
Candidate Name:
Candidate Number:
Date:
Version 1 14 © OCR 2018