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
30
Location
Place
Website
Visit site
XP
506
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
  • NinStar @ NinStar:
    there is a plugin that display them on the wii u menu, pretty sure it is enabled by default
  • crafthp434 @ crafthp434:
    so like it doesnt exist
  • crafthp434 @ crafthp434:
    yeah
    ?
  • NinStar @ NinStar:
    it doesn't exist, at least not for aroma
  • crafthp434 @ crafthp434:
    ohhhhh
  • NinStar @ NinStar:
    on tiramisu you can access it by opening mii maker
  • crafthp434 @ crafthp434:
    okay
  • NinStar @ NinStar:
    I don't have a wii u anymore to test it myself, but if homebrews are not visible on the wii u menu I think you can press L + R + minus to open the plugin menu, there should be an option called "homebrews on wii u menu" or something similar
  • crafthp434 @ crafthp434:
    nope
  • crafthp434 @ crafthp434:
    it is L+dpad down+ select
  • crafthp434 @ crafthp434:
    but homebrew is appearing in the home menu btw
  • NinStar @ NinStar:
    yes, now I remember it
  • NinStar @ NinStar:
    then it is working, I also don't like that they did this but it is the only option you have if you are using aroma
  • crafthp434 @ crafthp434:
    i just didint know the homebrew launcher didint exist in aroma
  • crafthp434 @ crafthp434:
    thanks btw
  • Xdqwerty @ Xdqwerty:
    Im downloading fallout 3 goty edition
    +1
  • BigOnYa @ BigOnYa:
    I'm downloading more ram for my hamster pc
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    New hamster PC, with anal operation and BT connectivity!
    +1
  • Xdqwerty @ Xdqwerty:
    @BigOnYa, How do I make enemies respawn on gdevelop after
    the player dies?
  • Psionic Roshambo @ Psionic Roshambo:
    Carrying a PC or phone is so old school!
  • Psionic Roshambo @ Psionic Roshambo:
    Squeeze your cheeks twice to answer calls!
  • BigOnYa @ BigOnYa:
    @Xdqwerty you can use a "spawner" function on any object.
    +1
  • BigOnYa @ BigOnYa:
    Or when your player dies, you can say in code, if enemy exists, do nothing, but if enemy does not exist, then create enemy at certain spot. (This would be a pain tho for lots of emeies)
    +1
  • BigOnYa @ BigOnYa:
    Easiest, simple way would be just restart scene, but player would restart from beginning.
  • Xdqwerty @ Xdqwerty:
    @BigOnYa, thx in advance
    +1
    Xdqwerty @ Xdqwerty: @BigOnYa, thx in advance +1