They offer different flash templates with latest features.
Login

Forgot password
Register
Latest changes

The idea module was updated:

  • We now have 10 statuses instead of 5
  • The review process now involves both moderators and developers
  • Moderators can now review form and content separately
  • Moderators can now delegate decisions to developers when they are unable to assess the pertinence or feasibility of an idea
Improve this website
  • Report bugs here.
  • Register ideas for improvements using the idea module on this website.
Back
Written by:
ulysses
Score: 2
votes: 7
Format: Article

 Play with Python 2




perhaps you still relish one or two loops

open a terminal and start the interpreter




set the variable

>>> a = 0

and copy the yellow colored into the interpreter

>>> while a < 10 :
    a += 1
    print (a)

<return> 2 times



to say today you have learned and execute Fibonacci in Python
( maybe you a hacker? )

set the variables

>>> a = 0
>>> b = 1

and copy the yellow colored into the interpreter

>>> count = 0
max_count = 20
while count < max_count:
    count = count + 1
    #
    old_a = a
    old_b = b
    a = old_b
    b = old_a + old_b
    #
    #
    print (old_a),

<return> 2 times


and copy it into the interpreter once more


>>> count = 0
max_count = 20
while count < max_count:
    count = count + 1
    #
    old_a = a
    old_b = b
    a = old_b
    b = old_a + old_b
    #
    #
    print (old_a),


<return> 2 times


the variables (or values ​​to be assigned to them)
can be accessed anytime

>>> a
<return>

>>> b
<return>



a permanent background loop would thus provide constant values

have phun ;-)








 


Tags: python, programming
Created: 1 year ago.
Last edited: 1 year ago.
Reviewed: 1 year ago.
Read 0 times.

Comments
1 year ago

hithirdwavedust
Ok, took me a minute to figure out the browser's interpretation of tab. I'm a little bit sad about what the standard browser behavior has done to indentation. (and linguistic formatting in general)  
1 year ago

JohnYate
By asking you to copy and paste his sample code, ulysses misses the opportunity to mention/explain that the python language uses tab indentation to express (some would say "hide") block structure in iterated and other conditionally executed code.
I only found this out by typing in the text of the code long-hand: the interpreter kept complaining about the absence of indentation in what I had typed, and would only be placated by my inserting tabs, rather than spaces.
On the other hand, I only discovered this by working my way through the tutorial ...
 

Other tutorials from ulysses