Code Monkey home page Code Monkey logo

python-deepdive's People

Contributors

cbkinase avatar chandru-shane avatar compliance-user avatar fbaptiste avatar jdcatapult avatar kanagarajnn avatar muralidharanr19 avatar naeem-bebit avatar p-luber avatar vpopovec avatar williemaddox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-deepdive's Issues

C++ or Python?

Sir which is better for competitive programming - Python or C++
Sir urgent help needed
Pls guide me through it

Typo: should spelt as shgoudl

In file Part 1/Section 02 - A Quick Refresher/07 - Classes.ipynb, in the 2nd paragraph after Cell 1, the word, should is spelt as shgoudl.

Note that using self is just a convention (although a good one, and you shgoudl use it to make your code more understandable by others), you could really call it whatever (valid) name you choose.

Solution to Project 2 offered up earlier than expected.

In the following file, /python-deepdive/Part 2/Section 05 - Project 2/01 - Project - Description.ipynb, the line just before the code blocks begin reads,

Code from Previous Project

However, the code presented is actually the solution to the current project.

The expression ((i * j for j in range(start, stop + 1)) for i in range(start, stop + 1)) will result in wrong values!

In Part 2 > Section 06 - Generators > 05-Generator Expressions.ipynb at cell number 34, the following expression is used

((i * j for j in range(start, stop + 1)) for i in range(start, stop + 1))

as an equivalent to the following expression

[[i * j for j in range(start, stop + 1)] for i in range(start, stop + 1)]

But they will not generate the same result. The first expression will result in the following functions,

def mult_list():
    global start, stop
    for i in range(start, stop + 1):
        def inner():
            global start, stop
            nonlocal i
            for j in range(start, stop + 1):
                yield i * j

        yield inner()

we can see that the inner function is a closure, and i is the free variable. So the value of i which will be used to create the generator, is 10, which results in the following

[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]

But the very first expression [[i * j for j in range(start, stop + 1)] for i in range(start, stop + 1)] results the following

[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
 [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],
 [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],
 [4, 8, 12, 16, 20, 24, 28, 32, 36, 40],
 [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],
 [6, 12, 18, 24, 30, 36, 42, 48, 54, 60],
 [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],
 [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],
 [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],
 [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]

I was wondering if there is any fix to this!!!

Typo: repeating spelt as repeatg

In file Part 1/Section 02 - A Quick Refresher/04 - The While Loop.ipynb the word repeatg seems to be a typo.

While Loops

The while loop is a way to repeatg a block of code as long as a specified condition is met.

while : code block ...

Documentation unclear.

In the following file, /python-deepdive/Part 2/Section 06 - Generators/02 - Example - Fibonacci Sequence.ipynb, the following line is unclear:

but we'll still run in Python's maximum recursion depth
I was going to change it to,
but we'll still run into Python's maximum recursion depth
but that still sounded a bit off. I'll let you decide.

Duplicate Files.

In the directory, /python-deepdive/Part 2/Section 08 - Iteration Tools/,
02 - Slicing Iterables.ipynb
and
03 - Slicing Iterables.ipynb
are duplicates.

Second version of the custom cache function won't work if we have duplicate arguments.

Hi Fred.
At the end of the file Part 3/Section 05 - Sets/06 - Frozen Sets.ipynb, we created a custom function for memoization replacing the lru_cache.

The second version of it is:

We can even tweak this to effectively provide more efficient caching when the order of positional arguments is not important either:

def memoizer(fn):
    cache = {}
    def inner(*args, **kwargs):
        key = frozenset(args) | frozenset(kwargs.items())
        if key in cache:
            return cache[key]
        else:
            result = fn(*args, **kwargs)
            cache[key] = result
            return result
    return inner

@memoizer
def adder(*args):
    print('calculating...')
    return sum(args)

I just wanted to note that this cache mechanism won't work if we have duplicate arguments. That set (frozenset actually) removes the duplicate arguments.

Take a look at this example:

print(adder(1, 2, 2))
print(adder(1, 1, 2))  # 5 !!

You may add a note that arguments should be different for this to work.
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.