Gaming How to conver code to an algorithm?

kevan

Imagination rules the world
OP
Member
Joined
Dec 4, 2009
Messages
1,378
Trophies
0
Age
29
Location
Place
Website
Visit site
XP
496
Country
Code:
import time

while True:
value = int(input("Anti-Bot Test: Enter a number under 5 (leave blank to quit): "))
if not value:
break
elif value < 5:
print ("Passed")
break
else:
print ("Failed")

if value:
username = input("Enter Username: ")
password = input("Enter Password: ")
password2 = input("Re-enter Password: ")


while (password != password2):
print ("Second password doesn't match the first password")
print ("Re-enter your original password")
password2 = input("")
dob = input("Date of Birth: ")
print ("Review the following information")
time.sleep(1)
print ("You would like your username to be: %s" % (username))
print ("Your date of birth is: %s" % (dob))
y=['yes']
yn=str(input("Type yes to confirm information or no to revise it: "))
if yn in y:
print ("Thank you for registering")
I need it if they type no they go back to entering their username. Also if they type anything else except 'yes' or 'no' it tells them that is wrong and to type 'yes or 'no' again.
Thanks for the help so far guys :yaynds:
This is the code I have and I'm curious on how I would convert it back to an Algorithm? Also the question I have there in the quote. Any help with that please! :)
 

kirlac

Well-Known Member
Newcomer
Joined
May 17, 2009
Messages
49
Trophies
0
Age
36
Website
Visit site
XP
123
Country
New Zealand
Since an algorithm is just the step by step of what needs to happen you just read the code and write what each part is doing eg.
In a loop
Take in input to determine user is not a bot
Check if input is less than 5
etc.

As for the question, perhaps use some while loops eg.
create variable repeating set to true
while repeating
enter login
ask question
while answer is not yes or no
ask question again
if answer is yes
do yes scenario
set repeating to false
else set repeating to true
end loop
end loop

EDIT: Forgot to create repeating variable (initialized as true) and set it to false when doing the yes sceneario to prevent infinite loop.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • K3Nv2 @ K3Nv2:
    I've been taking fiber pills, eating more grapes, switched to wheat bread in hopes to lower it
    +1
  • BigOnYa @ BigOnYa:
    I like wheat bread, I even like the chunky wheat bread with pieces of whole grain in it.
  • K3Nv2 @ K3Nv2:
    Been getting this honey wheat bread from aldis pretty decent not very sweet to out do it
  • K3Nv2 @ K3Nv2:
    Me making any food at home is an improvement to how I use to be
    +1
  • BigOnYa @ BigOnYa:
    I have an bread machine and use it alot, better than breads you buy, but don't last as long, cause no bs preservatives
  • K3Nv2 @ K3Nv2:
    I got compliments about my weight loss and thought well guess I can pig out again now I'm the piggy
  • BigOnYa @ BigOnYa:
    My biggest prob is alcohol, definitely is fattening
  • K3Nv2 @ K3Nv2:
    I know when to stop at least honestly don't get those that go and go with food
  • BigOnYa @ BigOnYa:
    Or those that order 2 big macs , large fry, ice cream sundie, then a diet coke
  • K3Nv2 @ K3Nv2:
    I might get downing two big macs but nah that's it
  • BigOnYa @ BigOnYa:
    Ok that will be $15.99, cash or charge?
  • K3Nv2 @ K3Nv2:
    My go to orders usually a mcdouble and a mcchicken and I'm happy rarely mess with fries
  • K3Nv2 @ K3Nv2:
    Pro tip ask for that clowns jizzmac sauce on your mcdouble
    +1
  • BigOnYa @ BigOnYa:
    Do they charge extra when you add sauce,etc? I know burger king used to not, but don't know nowadays
  • K3Nv2 @ K3Nv2:
    They may squrit it for free if you ask nice
    +1
  • K3Nv2 @ K3Nv2:
    Last time I got bk it was 35c per sauce fuck you king of my nutsack
    +1
  • K3Nv2 @ K3Nv2:
    I'll buy a bottle of baby rays BBQ for $2 and add it from home out of spite
    +1
  • BigOnYa @ BigOnYa:
    I like baby rays, my favorite is KC masterpiece tho. Figured all you could buy is that there.
  • K3Nv2 @ K3Nv2:
    The metro doesn't discriminate good sauce
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    Baby Rays isn't that what killed the crocodile hunter?
  • Psionic Roshambo @ Psionic Roshambo:
    If only he had done an endorsement for them....
  • Psionic Roshambo @ Psionic Roshambo:
    Oy mate don't let a bad bbq sauce kill your party! Baby Rays are killing it!! The flavor hits you right in the chest!
    +1
  • Xdqwerty @ Xdqwerty:
    My phone only has 13% battery so i don't have much time left
  • Xdqwerty @ Xdqwerty:
    Now 12%
  • BigOnYa @ BigOnYa:
    Happy birthday, btw
    BigOnYa @ BigOnYa: Happy birthday, btw