0% found this document useful (0 votes)
11 views14 pages

Max OConnell

Uploaded by

qiao lin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views14 pages

Max OConnell

Uploaded by

qiao lin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Centre Name: Centre Number:

Task Completed: The Song Task

Date started Date completed


1/12/2020 8/2/2022

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

 Remember to try and use normal, boundary and erroneous tests.

 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():

print("Welcome to the Game")

start=input("1)Sign in 2)Create Login")

if start == "1":

sign_in()

if start == "2":

create_login()

def sign_in():

datafile=open("login.csv","r")

logins=[]

for line in datafile:

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:

user = input("Enter Username\n")

for item in logins:

if user == item[0]:

print("Username Accepted")

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] :

print("Welcome!")

check = True

break

else:

print("User and pass not in the data base")

password=input("Re-enter password")

Candidate Name:
Candidate Number:
Date:
Version 1 7 © OCR 2018
Centre Name: Centre Number:

def 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()

print(logins)

for details in logins:

if username==details[0]:

print("Username taken try again")

create_logins()

else:

print("Username accepted")

break

password=input("Enter password:")

password2=input("Re-enter password:")

if password == password2:

print("details successfully stored")

Candidate Name:
Candidate Number:
Date:
Version 1 8 © OCR 2018
Centre Name: Centre Number:

with open("login.csv","a", newline="")as csvfile:

writer=csv.writer(csvfile)

writer.writerow([username, password])

intro()

import csv

import random

user_scores=[]

with open("Song_list.csv")as csvfile:

songs = list(csv.reader(csvfile))

username =input("Enter username")

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

while count < 10:

r= random.choice(songs)

points = 3

print(r[2])

user=input("Enter Guess")

if user.lower() == r[1]. lower():

print("Correct")

score+=1

count+=1

user_scores.append([username, score])

print(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)

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

 Identify if you needed to make changes to your program

 Include the screenshots of the tests

My tests:

Do I need to change my program?


Test What am I testing? Expected result Pass/Fail
If so, how?
1 Login Function Welcome! Pass N/A
2 Login Function Don’t let it login Fail It should take you back to the start
instead of asking for another password
3 Test whether song is Song is displayed Pass N/A
displayed
4 Test user input for Correct and +1 point Fail It doesn’t show whether the song is
song guess correct and points are not added
5 Test user input for Incorrect and You get Fail It doesn’t show whether the song is
song guess another go correct and points are not added plus
you do not get another go

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.

 You should reflect on any new skills you have developed

This section should be approximately 200-500 words.

How successful was my program?

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

What new skills have I developed?

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

You might also like