Turn on thread page Beta

Python Login System For Computer Science Controlled Assesment watch

    • Thread Starter
    Offline

    7
    ReputationRep:
    I NEED a login/register system that saves usernames and passwords so users can log in to their accounts again (it's for a quiz so the scores they get in the quizzes will be saved to their accounts in an ext text file)
    It would be good if the usernames and passwords could be stored in arrays as well.
    thanks, Joe
    • Thread Starter
    Offline

    7
    ReputationRep:
    :/
    That was my first option but it doesn't really work
    • Thread Starter
    Offline

    7
    ReputationRep:
    users = {} status = "" print ("hello and welcome to my subject quiz on History,Music and Computer science") print ("") def displayMenu(): status = input("Are you a registered user? y/n? Press q to quit: ") if status == "y": oldUser() elif status == "n": newUser() def newUser(): createLogin = input("Create login name: ") if createLogin in users: print ("Login name already exist!") else: createPassw = input("Create password ") users[createLogin] = createPassw print("User created!") status = "q" def oldUser(): login = input("Enter name: ") log = (login[0:3]) passw = input("Enter password: ") # check if user exists and login matches password if login in users and users[login] == passw: print ("Login successful!") status = "q" else: print ("User doesn't exist or wrong password!") while status != "q": displayMenu() while status == "q": print ("Now your age please") age = input() username = (log + passw) print ("Great your username is ") print (username) f = open('Username+Password.txt','a' ) f.write(username + " " + passw) f.close() quiz = ''
    • Thread Starter
    Offline

    7
    ReputationRep:
    done Its kind of like that and it dosent work. theres a continuos loop and i dont think ive done it efficiently
    • Thread Starter
    Offline

    7
    ReputationRep:
    U was trying to remember the error I had couldn't remember it though but thanks so much if I have any more errors they will be posted on Friday
    Posted on the TSR App. Download from Apple or Google Play
    Offline

    17
    ReputationRep:
    (Original post by FriendlyPenguin)
    TSR is badly coded, it seems to think lines are unimportant. I'll reformat you thing here a bit.

    users = {}
    status = ""

    print ("hello and welcome to my subject quiz on History,Music and Computer science"
    print (""

    def displayMenu():
    >>>>status = input("Are you a registered user? y/n? Press q to quit:
    >>>>"

    if status == "y":
    >>>>oldUser()
    elif status == "n":
    >>>>newUser()

    def newUser():
    >>>>createLogin = input("Create login name:"
    if createLogin in users:
    >>>>print ("Login name already exist!"
    else:
    >>>>createPassw = input("Create password "
    users[createLogin] = createPassw print("User created!"
    status = "q"

    def oldUser():
    >>>>login = input("Enter name:"
    log = (login[0:3])
    passw = input("Enter password:"
    # check if user exists and login matches password if login in users and users[login] == passw:
    >>>>print ("Login successful!"
    >>>>status = "q"
    else:
    >>>>print ("User doesn't exist or wrong password!"
    while status != "q":
    >>>>displayMenu()
    while status == "q":
    >>>>print ("Now your age please"
    age = input()

    username = (log + passw)
    print ("Great your username is "
    print (username)

    f = open('Username+Password.txt','a' )
    f.write(username + " " + passw)
    f.close()
    quiz = ''




    I'll just give you some tips.
    1) I prefer single quotes ' but that is just style
    2) print('Great, your username is '+username) is better (you can concatenate strings with '+' - or, even better, print('Great, your username is {0}'.format(username)) since you are using Python3
    3) You are calling newUser() before you have defined it <<< This is probably the issue. It is almost always advisable to define functions are the beginning of the script.
    4) If you want help, say what the error is, rather than just "it doesn't work". Or maybe the IDE you are using is unhelpful, in which case that isn't your fault.
    5) Probably cleaner to say:

    with open('Username+Password.txt','w' as f:
    >>>>f.write(etc)
    >>>>f.close()
    Goddamn TSR with the smiley faces xD
    • Thread Starter
    Offline

    7
    ReputationRep:
    I can't its in school the controled assessment
    Posted on the TSR App. Download from Apple or Google Play
    Offline

    10
    ReputationRep:
    (Original post by FriendlyPenguin)
    On Friday I won't be arsed, just like you obviously aren't right now.

    Has it really not occurred to you to run the script again?
    Students are only allowed to work on their CA in controlled conditions (in school) and are not allowed to take their code home/bring it in so they can't run their exact code now. I assume the code they pasted was just rough, from memory.
    • Thread Starter
    Offline

    7
    ReputationRep:
    Ye pretty much
    Posted on the TSR App. Download from Apple or Google Play
    Offline

    10
    ReputationRep:
    (Original post by FriendlyPenguin)
    Controlled Assessment is such a joke. People at my school knew people at other schools who had already done the test, so they walking in knowing the questions and answers.

    But OP may as well run the script s/he's written down.
    Yep, that's a good point. Unfortunately for me, my school started as soon as we got back so we will either be ahead of any other schools or at the same place :/


    I can figure out the code, but it is so tedious and I feel like it's pointless not allowing access to the internet.


    I have to keep trying to memorise bits of the code that I planned outside of lessons ready for the next lesson - because of the 20 hour time limit, I don't think I'd get it all done in time just figuring it out as I go.
    Offline

    17
    ReputationRep:
    (Original post by tsraccount_)
    Students are only allowed to work on their CA in controlled conditions (in school) and are not allowed to take their code home/bring it in so they can't run their exact code now. I assume the code they pasted was just rough, from memory.
    In my class there were pretty much two people who worked properly on our projects (inc. me). One day one of the other guys' friends asks for his code to compare it with his own. A week goes by and suddenly the entire class has it.

    Fortunately this was still fairly early on so most peoples projects changed a ton, but still goes to show how *****y the rule enforcement is.
    Offline

    1
    ReputationRep:
    (Original post by FriendlyPenguin)
    Well, I suggest you start writing it then!
    u start writing
    Offline

    1
    ReputationRep:
    yhhhhhh mannnn
    Offline

    1
    ReputationRep:
    (Original post by friendlypenguin)
    well, i suggest you start writing it then!
    noooooooooooo
    Offline

    1
    ReputationRep:
    (Original post by joe butler15)
    i need a login/register system that saves usernames and passwords so users can log in to their accounts again (it's for a quiz so the scores they get in the quizzes will be saved to their accounts in an ext text file)
    it would be good if the usernames and passwords could be stored in arrays as well.
    Thanks, joe
    (Original post by friendlypenguin)
    well, i suggest you start writing it then!

    you start writing
    Offline

    12
    ReputationRep:
    heres a link to one i made as the first prototype for my controlled assessment, the programming is simple you could learn enough at home in a week to do the scenario just put the work in here https://www.hastebin.com/bibihopuri.py
 
 
 
Poll
Is the Big Bang theory correct?
Useful resources

Study tools

Rosette

Essay expert

Learn to write like a pro with our ultimate essay guide.

Thinking about uni already?

Thinking about uni already?

See where you can apply with our uni match tool

Student chat

Ask a question

Chat to other GCSE students and get your study questions answered.

Creating

Make study resources

Create all the resources you need to get the grades.

Planner

Create your own Study Plan

Organise all your homework and exams so you never miss another deadline.

Resources by subject

From flashcards to mind maps; there's everything you need for all of your GCSE subjects.

Papers

Find past papers

100s of GCSE past papers for all your subjects at your fingertips.

Help out other students

Can you help? Study help unanswered threads

Groups associated with this forum:

View associated groups

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.