Skip to content
murmot

Results for “python while loop string example program install site:wiki.python.org 2”

  • wiki.python.org

    For Loop - Python Wiki

    There are two ways to create loops in Python: with the for-loop and the while-loop. When do I use for loops¶. for loops are used when you have a block of code ...

  • wiki.python.org

    While loops - Python Software Foundation Wiki Server

    While loops Usage in Python When do I use them? While loops, like the ForLoop, are used for repeating sections of code - but unlike a for loop, the while loop will not run n times, but until a defined condition is no longer met. If the condition is initially false, the loop body will not be executed at all. As the for loop in Python is so powerful, while is rarely used, except in cases where a ...

  • wiki.python.org

    Simple Programs - Python Wiki

    ') 11 lines: Triple-quoted strings, while loop. REFRAIN = ''' {} bottles of ... >>> median([2, 9, 9, 7, 9, 2, 4, 5, 8]) 6 #change to 7 in order to pass ...

  • wiki.python.org

    ForLoop

    There are two ways to create loops in Python: with the for-loop and the while-loop. When do I use for loops.When running the above example, you can stop the program by pressing ctrl+c at the same time. As you can see, these loop constructs serve different purposes.

  • wiki.python.org

    Getting Started - Python Wiki

    Simple Programs – progressively longer code examples, from one-liners to multi-class programs Simple Programs (Chinese) – the same graduated examples, translated into Chinese Learn Python – learning Python through XML, XSLT, and other practical code samples While Loop – a focused explanation of while loops with usage patterns

  • wiki.python.org

    Bit Manipulation - Python Wiki

    Some simple code is at ActiveState Code Recipes: Bit-field manipulation (in Python 2 syntax). ... 1 # loop pass 1 loop pass 2 2 # 101000 101000 100000 ...

  • wiki.python.org

    Python Speed / Performance Tips - Python Wiki

    Repeat from 2. Certain optimizations amount to good programming style and so should be learned as you learn the language. An example would be moving the calculation of values that don’t change within a loop, outside of the loop. Choose the Right Data Structure ¶ TBD. Sorting ¶ Sorting lists of basic Python objects is generally pretty efficient.

  • wiki.python.org

    Beginners Guide / Download - Python Wiki

    Simple Programs · Simple Programs Chinese · While Loop · GUI Programming · Guides ... install and setup Python here: https://docs.python.org/3/using/index.html.

  • wiki.python.org

    Generators - Python Wiki

    Generator functions allow you to declare a function that behaves like an iterator, i.e. it can be used in a for loop. Simplified Code ¶ The simplification of code is a result of generator function and generator expression support provided by Python. To illustrate this, we will compare different implementations that implement a function, “firstn”, that represents the first n non-negative ...

  • wiki.python.org

    Perl Phrasebook - Python Wiki

    add more points of comparison. Use sorted() where appropriate. Get rid of map() where possible. Simple types (strings, lists, dictionaries ...