Git Product home page Git Product logo

Comments (12)

gvwilson avatar gvwilson commented on May 13, 2024

from python-novice-gapminder.

alistairwalsh avatar alistairwalsh commented on May 13, 2024

Maybe defensive programming and incorporate checking if a key exists before modifying it's value as an example of defensive programming within the dicts lesson?

from python-novice-gapminder.

gvwilson avatar gvwilson commented on May 13, 2024

from python-novice-gapminder.

wking avatar wking commented on May 13, 2024

On Fri, Apr 01, 2016 at 04:22:45PM -0700, Alistair Walsh wrote:

I would like to see dictionaries introduced in the beginner
lesson. Lists and dictionaries are basic Python data types and it
seems appropriate to discuss dictionaries after lists.

Data structures (and algorithms) are important, and making good
choices there will make your life a lot easier. But I think the wrong
data structure in well-organized and -documented code will be easier
to recover from than the right data structure in undocumented
spaghetti (although the latter may work better in the short term). So
I'd rather keep the focus on the maintenance-oriented “good enough”
goals 1 instead of pulling in the more traditional comp-sci subjects
(which make more sense when you have access to learners for four years
than when you only have one day ;).

from python-novice-gapminder.

alistairwalsh avatar alistairwalsh commented on May 13, 2024

I wouldn't know what a traditional computer science course contains as I'm not from a computer science background. I'm from humanities and a large chunk of the beginners I teach are too (more and more so actually). They have a need for dictionaries because of the type of data they tend to have. Probably different from the harder sciences that the Numpy based lessons are aimed at.
If we are using Pandas as a vehicle to teach, not teaching dictionaries seems like a missing piece.

Maybe those "best practices" items like documentation, Style Guide, comments and defensive programming can be modelled by the instructor throughout the workshop without being a seperate lesson?

from python-novice-gapminder.

gvwilson avatar gvwilson commented on May 13, 2024

from python-novice-gapminder.

wking avatar wking commented on May 13, 2024

On Sat, Apr 02, 2016 at 04:32:57PM -0700, Greg Wilson wrote:

One option would be to cut the call stack (25 minutes), which would
mean not really explaining variable scope - is that a good
trade-off?

I think variable scoping should stay, since writing functions etc. is
going to be pretty confusing without at least knowing that variable
scope is a thing.

Extending @alistairwalsh's Pandas comment, maybe we should just
double-down on Pandas and skip Python's native structures? With the
current ec9a909, folks are using read_csv 1 to get a DataFrame from
a CSV file. The docs describe DataFrames as “think of it like a
spreadsheet or SQL table, or a dict of Series objects” 2. So we can
probably cover both string indexing and integer indexing / slicing
with the DataFrame from read_csv, and skip describing how to construct
a DataFrame from native Python data types. So something like:

  • Drop 11-lists.md (saves 15 minutes) (lists are also not mentioned in
    the “good enough” practices).
  • Extend 09-data-frames.md's teaching from 10 to 15 minutes, and use
    that time to talk about:
    • How DataFrames help you organize your data,
    • That there are a number of other data structures (name-dropping
      lists and dicts, but not going into much detail) that are common
      to many programming languages, and
    • That picking the right data structure can make your life easier,
      so it's worth reading around when you start a new project to see
      what sorts of things other people use.
  • Add a 5 minute teaching / 5 minute exercise topic on to_csv 3, so
    folks can write chainable tools (e.g. initial CSV → tool A → CSV →
    tool B → CSV …). I'd put this after 20-style.md, since you can use
    the style topic to bridge “modular, comprehensible, reusable” from
    the per-function scale to the per-script scale, and then switch from
    theory to practice by writing a single script that could fit into a
    longer chain.

from python-novice-gapminder.

kevin-vilbig avatar kevin-vilbig commented on May 13, 2024

A dictionary is a relatively complex data structure that would be more suited to a second, intermediate lesson on Python rather than a day one, one-day, beginner course. Yes, it is considered to be a basic data type to Python, but that is only because it is a built-in type. It is not a simple structure, by any means. Back when I took the CompSci AP test after a year-long programming course, however many years ago, hash tables were not even mentioned. We don't even discuss the difference between lists and tuples in the given curriculum.

I think it's the difference that lists/mutable arrays are ubiquitous across a variety of programming languages, and dicts/hash maps/hash tables aren't. They are useful and awesome, which is why they were built-in to Python in the first place, but that doesn't mean we shoud be trying to lever in list comprehensions, generator functions, and all of the other cool stuff that Python can do into the first-day workshop.

from python-novice-gapminder.

alistairwalsh avatar alistairwalsh commented on May 13, 2024

Just to clarify, I'm not suggesting teaching list comprehension, generators or hash tables. I'm suggesting showing how to create a dictionary, how to access the data in a dictionary and pointing out what type of data they suit. Dictionaries are common and I'd like the beginners to know what they are and how they work when they encounter them.

from python-novice-gapminder.

wking avatar wking commented on May 13, 2024

On Thu, Apr 14, 2016 at 06:20:00PM -0700, Alistair Walsh wrote:

Just to clarify, I'm not suggesting teaching list comprehension,
generators or hash tables. I'm suggesting showing how to create a
dictionary, how to access the data in a dictionary and pointing out
what type of data they suit.

I agree that this is useful stuff (and I'm particularly fond of JSON's
flow-chart syntax diagrams 1, although they call these structures
“objects”). I just think we can teach these ideas without introducing
anything beyond DataFrames (which we're already planning on handling)
2. What do native dictionaries get you that teaching those ideas
via DataFrames does not?

from python-novice-gapminder.

tobyhodges avatar tobyhodges commented on May 13, 2024

I'm +1 on the comments that @fu9ar made about dictionaries. They are a central data structure in Python, but many scientists can - and do - program for quite a while without ever needing them.

I recently taught a beginner-level Python course to an audience of scientists. The material isn't aimed at a scientific audience, and contains a chunk of stuff covering dictionaries. I was surprised when a few people told me that they'd been using Python for their work for a while, and that this was the first they'd heard about dictionaries!

Clearly, this isn't ideal - at least one person said that they'd recently gone to great lengths to recreate the behaviour of a dictionary using numpy arrays - so perhaps it's something to point people towards in notes/at the end of the session, along with other data structures such as sets, counters, the collections module and so on?

from python-novice-gapminder.

lexnederbragt avatar lexnederbragt commented on May 13, 2024

I also know a Ruby programmer that managed programming with much complexity without being aware of dictionary-type data structures. They can be a leap for some to understand, though. I once taught total novices perl, and they got lists, but hashes (perl’s dictionary equivalent) was very abstract for them and took a long time to sink in...

from python-novice-gapminder.

Related Issues (20)

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.