The Student Room Group

can anyone help me code for computer science?

I need help doing the NEA. it is a music quiz game that I need to progamme
what exam board is it?
Reply 2
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()

Quick Reply

Latest