can anyone help me code for computer science?

Watch
camdog
Badges: 2
Rep:
?
#1
Report Thread starter 2 years ago
#1
I need help doing the NEA. it is a music quiz game that I need to progamme
0
reply
wizkid44
Badges: 18
Rep:
?
#2
Report 2 years ago
#2
what exam board is it?
0
reply
mp__786
Badges: 5
Rep:
?
#3
Report 2 years ago
#3
Please can you help me figure out why this code aint working. What external files need to be added. Dont mind the dedents.


import sys
import random
import tkinter
from tkinter import *
count = 1
while count == 1:
username=str(input("what is your name"))
password=str(input("enter your password"))
userandpass= ((password) + (username))


f = open('test.txt','a+')



if (userandpass) in open('test.txt').read():
print("welcome back " + (username))
f.close()
count = count+ 1

else:
print("sadly you dont exist yet, we will set up an account!")
f.write(" " + (userandpass) + " ")
f.close()
f.close()




score = 0
file = open("artists.txt", "rt")
lines = file.readlines()
contents = (lines[2])
line = (contents)
two = (lines[2])
file.close()

file = open("artists.txt", "rt")
lines = file.readlines()


contents = (lines[3])
line = (contents)
three = (lines[3])
file.close()

file = open("tracks.txt", "rt")


lines = file.readlines()
x = 1
goes = int(input("how many goes"))
goes1 = goes + 1
for x in range (1,(goes1)):
select = random.randint(1,2)








if select == 1:
attempts = 0


while True:

contents = (lines[2])
line = (contents)
words = line.split()
letters = [word[0] for word in words]
print ("".join(letters) + " " + three)
guess = input("what do you guess")

true()

if guess != ("eyes of a panther") and attempts == 0:
print("wrong! one go left!")
attempts = attempts + 1
print(score)
guess = input("what do you guess")
if guess != ("eyes of a panther") and attempts == 1:
print("you lose")
print(score)
sys.exit()
if guess == ("eyes of a panther") and attempts == 0:
score = score + 3
print (score)
x = x + 2
if guess == ("eyes of a panther") and attempts == 1:
score = score + 1
print(score)



if select == 2:
attempts = 0

while True:
contents = (lines[1])
line = (contents)
words = line.split()
letters = [word[0] for word in words]
print ("".join(letters) + " " + two)
guess = input("what do you guess")
true()

if guess != ("i like drugs") and attempts == 0:
print("wrong! one go left!")
attempts = attempts + 1
print(score)
guess = input("what do you guess")
if guess != ("i like drugs") and attempts == 1:
print("you lose")
print(score)
sys.exit()
if guess == ("i like drugs") and attempts == 0:
score = score + 3
print (score)
x = x + 2
if guess == ("i like drugs") and attempts == 1:
score = score + 1
print(score)


score1 = str(score)
topscores = open("topscores.txt", "a+")
topscores.write((score1) + ',' + (username) + "\n")
topscores.close()
top=tkinter.Tk()
def scores():
import csv
import operator
tester= open("top5scores.txt", "a+")

winnerfile = open("topscores.txt", "r")
csv1 = csv.reader(winnerfile,delimiter= ',')

sort = sorted(csv1,key=operator.itemgetter(1), reverse=True)
for eachline in sort:
string=str(eachline)
tester.write(string + "\n")
print("\n" + string + "\n")

remove =+ 1
if remove >= 5:
f = open( 'top5.txt', 'r' )
lines = f.readlines()
f.close()
f = open( 'top5.txt','w' )
f.write( '\n'.join( lines[1:] ) )
f.close()
A = tkinter.Button(top, text="Click me for score", command = scores)
A.pack()

score()
0
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

How do you prefer to get careers advice?

I like to speak to my friends and family (18)
8.74%
I like to do my own research online using careers specific websites (125)
60.68%
I like speaking to the careers advisors at school, college or uni (30)
14.56%
I prefer to listen watch videos or listen to podcasts of people in my chosen career (29)
14.08%
Something else (let us know in the thread) (4)
1.94%

Watched Threads

View All