Skip to content

some comments on "How much math can you do in 10 lines of Python" #22

@jablka

Description

@jablka

I have realized that your code examples use in fact some Python 2.x functions:
xrange() and print (without parentheses).
.
Also, I suspect that python doesn't have a tuple comprehension.
It seems to me that the code that produces a tuple in your example:
tuple(2*v for v in (1.0, 4.0, 3.0))
uses in fact a generator comprehension.
Which can be also used here: sum(i for i in range(5)) # returns: 10
Because both functions accept iterables as arguments, and since generator is iterable, it goes through it.
.
Anyway, I like the website!
Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions