chevron_left chevron_right
Login Register invert_colors photo_library


Stay updated and chat with others! - Join the Discord!
Thread Rating:
  • 0 Vote(s) - 0 Average


Types of Loops (That I Use) filter_list
Author
Message
Types of Loops (That I Use) #1
This is just a list of loops that I do, maybe you guys could use these loops in your Python Programming and such.

The "Forever" Loop:

This is a really simple loop.

Code:
def loop1():
    loop2()

def loop2():
    loop1()

Basically, you have loop2 to do functions and such or whatever you want it to do and it automatically goes to loop1, which goes back to loop2.

The Prompt Loop:

Basically you just prompt the user if they want to continue. Depending on their response, it may or may not loop. However, this isn't necessarily a loop since it isn't always used as a loop.

Code:
def loop():
    shithere

_input = input('Do you want to continue?')
if _input == 'y':
    loop()
elif _input == 'n':
    print('Bye!')
else:
    print('Unknown response')

[color=#FF0000]The For Loop:[/color]

This is probably one of the most known, and one of the most least used (by me) loops.

[code]
for flafjkgafjkhg in range(1,99):
    print('We're on number {0}'.format(flafjkgafjkhg))

This loop checks what number or whatever the fuck in the range and prints it. It doesn't have to print it, this is useful, very.

An example of other uses would be in my Cheerio-Shitter DoS tool.

Code:
instances = random.randint(50,500)
for i in instances(1,instance):
    dos()

These are the loop-types that I use, and what they do. Maybe this was helpful for you, it does have a learning aspect, so don't say it doesn't teach you anything.

Reply

RE: Types of Loops (That I Use) #2
#1. This is called recursion, it isn't, strictly speaking, a loop.

#2. The example isn't even a loop, it's a bunch of conditionals. The "loop" function will only get called once.

#3. You don't use them often because you use python, which has an "in" keyword. In other languages, you almost always have to use a for loop to iterate through arrays.
micrictor@creep.im

Reply

RE: Types of Loops (That I Use) #3
Confusedtart
echo Hi
goto Start

#batchmasterrace
free @pvnk

Reply

RE: Types of Loops (That I Use) #4
(03-09-2014, 05:28 AM)w00t Wrote: ...
#3. You don't use them often because you use python, which has an "in" keyword. In other languages, you almost always have to use a for loop to iterate through arrays.

Python's for x in y is still a loop.
[Image: jWSyE88.png]

Reply

RE: Types of Loops (That I Use) #5
(03-09-2014, 07:37 AM)3SidedSquare Wrote: Python's for x in y is still a loop.

As both his examples used number loops, I presumed that he intended to only discuss for loops involving range/xrange.
micrictor@creep.im

Reply

RE: Types of Loops (That I Use) #6
(03-09-2014, 05:32 AM)Satan Wrote: Confusedtart
echo Hi
goto Start

#batchmasterrace
Code:
:start
start cmd /k start cmd
start http://meatspin.com/
goto start
#trollmasterrace

Reply

RE: Types of Loops (That I Use) #7
What about funrolled loops? pleb.
[Image: 383dbcbdd0eb954803ad9bc4f8934f82.png]

Reply

RE: Types of Loops (That I Use) #8
(03-09-2014, 08:58 AM)Aurora Wrote:
Code:
:start
start cmd /k start cmd
start http://meatspin.com/
goto start
#trollmasterrace

* Cressi is *Curious as to what this "meatspin.com" is; and enters it in URL bar*

You will burn forever for this, Aurory.
[Image: R5aCcWV.png]

Reply

RE: Types of Loops (That I Use) #9
(03-09-2014, 06:05 PM)Cressi Wrote: * Cressi is *Curious as to what this "meatspin.com" is; and enters it in URL bar*

You will burn forever for this, Aurory.

HAHAHAHAHAHAHAHAHAHAHAHAHAHAH. LOOOOOOOL. I thought it was obvious?!! xD

Reply

RE: Types of Loops (That I Use) #10
(03-09-2014, 07:39 PM)Aurora Wrote: HAHAHAHAHAHAHAHAHAHAHAHAHAHAH. LOOOOOOOL. I thought it was obvious?!! xD

I was expecting a butcher's shop...

* Cressi is scarred forever now...
[Image: R5aCcWV.png]

Reply






Users browsing this thread: 1 Guest(s)