Can someone convert this python into pseudo code please? Watch

Samuel.King
Badges: 2
Rep:
?
#1
Report Thread starter 9 months ago
#1
Can someone convert this into pseudo code for me please?

def Admin():
attempts = 3
while attempts != 0:
password = "1a2b3c"
userpass = input("\nEnter the administrator password: "
if password == userpass:
userfile = open("userfile.csv", "w"
WriteLine = "Username" + "," + "Password" + "," + "Security" + "\n"
userfile.write(WriteLine)
userfile.close()

scorefile = open("scorefile.csv", "w"
WriteLine = "Username" + "," + "Score" + "\n"
scorefile.write(WriteLine)
scorefile.close()
print("\nCSV files created!"
Last edited by Samuel.King; 9 months ago
0
reply
Acsel
Badges: 20
Rep:
?
#2
Report 9 months ago
#2
(Original post by Samuel.King)
Can someone convert this into pseudo code for me please?

def Admin():
attempts = 3
while attempts != 0:
password = "1a2b3c"
userpass = input("\nEnter the administrator password: "
if password == userpass:
userfile = open("userfile.csv", "w"
WriteLine = "Username" + "," + "Password" + "," + "Security" + "\n"
userfile.write(WriteLine)
userfile.close()

scorefile = open("scorefile.csv", "w"
WriteLine = "Username" + "," + "Score" + "\n"
scorefile.write(WriteLine)
scorefile.close()
print("\nCSV files created!"
Why should anyone do your work for you?

Can you tell us what this code is actually doing? If so, you basically have your pseudocode right there. It's not overly complicated so if you work through it line by line you'll be able to see what it's doing.
Last edited by Acsel; 9 months ago
0
reply
534443
Badges: 6
Rep:
?
#3
Report 9 months ago
#3
What's 'pseudo code' supposed to be?
0
reply
Acsel
Badges: 20
Rep:
?
#4
Report 9 months ago
#4
(Original post by 534443)
What's 'pseudo code' supposed to be?
The simplest explanation for pseudocode is that it's English like statements which describe the logic of some code. It can be used to plan out what you need your code to do before you write it, or you can turn existing code back into English statements so that it's easier to understand. The emphasis is on making code human readable, rather than machine readable.
0
reply
yt7777
Badges: 18
Rep:
?
#5
Report 9 months ago
#5
(Original post by Samuel.King)
Can someone convert this into pseudo code for me please?

def Admin():
attempts = 3
while attempts != 0:
password = "1a2b3c"
userpass = input("\nEnter the administrator password: "
if password == userpass:
userfile = open("userfile.csv", "w"
WriteLine = "Username" + "," + "Password" + "," + "Security" + "\n"
userfile.write(WriteLine)
userfile.close()

scorefile = open("scorefile.csv", "w"
WriteLine = "Username" + "," + "Score" + "\n"
scorefile.write(WriteLine)
scorefile.close()
print("\nCSV files created!"
Why would you need to write this in Pseudocode? Just describe line by line what its doing and you have your answer.

Also... might want to add this to your if statement or it will never terminate when the maximum attempts get reached

Spoiler:
Show

else: attempts = (attempts -1)
0
reply
Acsel
Badges: 20
Rep:
?
#6
Report 9 months ago
#6
(Original post by yt7777)

Also... might want to add this to your if statement or it will never terminate when the maximum attempts get reached

Spoiler:
Show


else: attempts = (attempts -1)

I mean if we want to start identifying coding errors too, there's a whole bunch of statements missing brackets
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

University open days

  • Bournemouth University
    Midwifery Open Day at Portsmouth Campus Undergraduate
    Wed, 16 Oct '19
  • Teesside University
    All faculties open Undergraduate
    Wed, 16 Oct '19
  • University of the Arts London
    London College of Fashion – Cordwainers Footwear and Bags & Accessories Undergraduate
    Wed, 16 Oct '19

How has the start of this academic year been for you?

Loving it - gonna be a great year (128)
18.23%
It's just nice to be back! (192)
27.35%
Not great so far... (251)
35.75%
I want to drop out! (131)
18.66%

Watched Threads

View All