Giter VIP home page Giter VIP logo

python's Introduction

Header image for the Python workshop

Python is a general-purpose programming language suitable for a wide variety of tasks in the digital humanities. Learning Python fundamentals is a gateway to analyzing data, creating visualizations, composing interactive websites, scraping the internet, and engaging in the distant reading of texts. This workshop first introduces participants to core programming concepts such as data types, variables, and functions. Participants will then learn about basic control flow by writing small programs with loops and conditional statements. They will also learn to problem solve, and practice searching for answers and debugging scripts. The workshop wraps up by exposing participants to intermediate tools for further exploration.

In this workshop, you will:

  • Understand what Python is and, in general terms, what it can do.
  • Run Python programs, both by interacting directly with the interpreter and by preparing and running scripts.
  • Distinguish among five core data types—integers, floats, strings, booleans, and lists.
  • Become familiar with core programming concepts, including variables, loops, and conditionals.
  • Engage with error output and use the internet and documentation to independently research language features.
  • Learn how to find and import code from external sources to solve more complex problems.

This workshop is estimated to take you 3-4 hours to complete.

Get Started


Lessons

  1. Interacting with Python
  2. Types
  3. Variables
  4. Running Scripts
  5. Errors in Python
  6. Functions
  7. Lists
  8. Loops
  9. Conditionals
  10. Input
  11. Doing Things to Lists
  12. Finding Answers with Google
  13. A Little Motivation
  14. Objects in Python

Before you get started

If you do not have experience or basic knowledge of the following workshops, you may want to look into those before you start with Introduction to Python:

  • Introduction to the Command Line (required) This workshop makes reference to concepts from the Command Line workshop, and having basic knowledge about how to use the command line will be central for anyone who wants to learn about programming with Python.
  • Installing Anaconda (recommended) You can use any installation of Python (but make sure it is of version 3) but for our purposes, Anaconda will provide everything necessary for all the workshops that are part of the DHRI curriculum.

Ethical Considerations

Before you start the Introduction to Python workshop, we want to remind you of some ethical considerations to take into account when you read through the lessons of this workshop:

  • Python works by reducing data to portable units and presenting them in a way that prioritizes readability. These units are known as "data types" and include strings (words/letters), integers (numbers), booleans (true or false statements), and lists (groups of strings). The python grammar, which dictates how python statements ought to be ordered, values simplicity, efficiency, and concision. You can read more about python values at the Zen of Python.
  • As we learn about the python data types and grammar, keep in mind that working within any digital format requires making seemingly neutral choices that carry ethical consequences. When using python, be aware of the ways the ways that data is transformed into computable form. What choices are you making about your data? What is being included, and what is left out? What are reductions and assumptions necessary to encode your data? If you are more interested in thinking further about data types and our choices in relation to data, you should have a look at our Data Literacies workshop.

Pre-reading suggestions

Before you start the Introduction to Python workshop, you may want to read a couple of our pre-reading suggestions:

Projects that use these skills

You may also want to check out a couple of projects that use the skills discussed in this workshop:

  • Built by former Digital Fellow Patrick Smyth, The NEH Impact Index makes visible the distribution of funds by National Endowment for the Humanities across the United States. The website uses python to map projects, communities, and cultural institutions who have received NEH support. You can check out the code on Github.
  • Mapping Arts NYC, created in 2019 by the Graduate Center's Data for Public Good fellows, "is a project that explores the geography and representation of arts and culture in New York City over time." It includes a number of Python scripts written to clean and make sense of all the data.
  • Python programmers build and maintain various "libraries," or collections of python code, that can be re-purposed toward custom projects. You might check out the Scrapy library for web scraping, the NumPy library for numerical computing, or the pandas library for data analysis and manipulation. Check out the individual websites to help you think about the data that you want to work with.

Get Started


Acknowledgements

This workshop is the result of a collaborative effort of a team of people, mostly involved presently or in the past, with the Graduate Center's Digital Initiatives. If you want to see statistics for contributions to this workshop, you can do so here. This is a list of all the contributors:


Digital Research Institute (DRI) Curriculum by Graduate Center Digital Initiatives is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. Based on a work at https://github.com/DHRI-Curriculum. When sharing this material or derivative works, preserve this paragraph, changing only the title of the derivative work, or provide comparable attribution.

Creative Commons License

python's People

Contributors

c-lane avatar gofilipa avatar kallewesterling avatar kchatlosh avatar lmrhody avatar smorello87 avatar smythp avatar szweibel avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

python's Issues

Complete a theory-to-practice.md file

  • Make sure you are in the right branch and have recently pulled all the content from the GitHub repository before you start working.

  • Create a theory-to-practice.md file in your repository
    Here, you can find the template for theory-to-practice.md. Copy the contents into a new file in your repository.

  • Add suggested further readings (optional)

    • Use ## Suggested Further Readings to indicate the beginning of the section, and bullet points for each of the sources (in markdown, you use - on a new line to create a bullet point).

    • If the reading has a DOI number, make sure to add it. If it does, you do not need to add any additional bibliographic information.

  • Add other tutorials (optional)
    Use ## Other Tutorials to indicate the beginning of the section, and bullet points for each of the sources (in markdown, you use - on a new line to create a bullet point).

  • Add projects or challenges to try (optional)
    Use ## Projects/Challenges To Try to indicate the beginning of the section, and bullet points for each of the projects/challenges (in markdown, you use - on a new line to create a bullet point).

  • Add discussion questions (optional)
    Use ## Discussion Questions to indicate the beginning of the section, and bullet points for each of the questions (in markdown, you use - on a new line to create a bullet point).

Add hands-on example at end of workshop

Final challenge for workshop, such as web scraping (or other task). Include a downloadable script that is relatively easy to read and understand, which participants can then modify for their own hands-on practice.

Currently working on a challenge with Beautiful Soup 4, but welcoming other suggestions! For the bs4 challenge, participants would download a ready script and copy/paste the URL that they want to scrape. There are also options for scraping other elements by un-commenting relevant lines.

Complete assessment.md

  • Make sure you are in the right branch and have recently pulled all the content from the GitHub repository before you start working.

  • Create a assessment.md file in the root directory of your repository
    Here, you can find the template for assessment.md. Copy the contents into the new file in your repository.

  • Complete the quantitative self-assessment section

    • Use ## Quantitative Self-Assessment to indicate the beginning of the section.

    • Move all the relevant quantitative self-assessment questions from DHRI/DRI exit slips found in the GCDI Google Drive over to this file.

    • Each question should be a regular paragraph.

    • Each question should have multiple choice answers, added as bullet points under the paragraph (in markdown, you use - on a new line to create a bullet point).

    • Make sure that the questions enable the learner to evaluate their understanding of specific concepts from the workshop.

  • Complete the qualitative self-assessment section

    • Use ## Qualitative Self-Assessment to indicate the beginning of the section.

    • Move all the relevant qualitative self-assessment questions from DHRI/DRI exit slips found in the GCDI Google Drive over to this file.

    • Each question should be a regular paragraph.

    • For each question, think of readings/tutorials/projects/challenges from the "Theory to Practice" section to direct them to, and add a note of that as a bullet point under relevant questions (in markdown, you use - on a new line to create a bullet point).

    • Make sure that the questions enable the learner to evaluate their understanding of specific concepts from the workshop.

Lessons: modify example content to reflect scholarly/humanities tasks

Some of the examples we use to teach core concepts (like the "weather app" to teach if/elif statements) reference things that might not be totally relevant to the kinds of work that our participants will be doing. We should revise the example content to better prepare and inform the tasks you can achieve with these skills.

For instance, instead of a weather app, how about a control flow example for cleaning text?

Welcoming suggestions!

Contribute to your User profile

Send to Kalle (via Slack):

  1. A headshot—make sure it is recent and as high-resolution as possible (if you have questions, feel free to reach out!).

  2. A bio—max 150 words.

  3. Any number of links to current websites and projects you have worked on and want to display.

  4. A "Meet your instructor" blurb (keep it short, less than 200 words) about why you got involved/how you have had use of the tool(s) that are introduced in your workshop.

    For this part, think about how you build trust and report with participants in digital research institute. Since we cannot build that if we don't meet participants in-person, how would you come up with language (narrative/rhetorical strategies) to provide a surrogate for this face-to-face interaction?

Add at least one evaluative question for each lesson

At this point, the lessons.md file should be complete enough that you will be able to go through each lesson and come up with (at least) one evaluative question per lesson, on what the learner should have picked up from the lesson. They should be expressed in the form of multiple-choice questions, with one or more correct answers.

How to add a multiple-choice question

Go through the lessons.md file, and for each lesson, create a new section at the end (## Evaluation) where you will add the question and each of the answers, marking the correct ones with a * at the end of it. (See an example here.)

Optional: Add open-ended questions

If you want to, in addition to the multiple-choice evaluative question, you can also raise an open-ended question, expressed as “Do you think you can answer this question:” As there is no easy way to programmatically understand the input in a text field to such a question (although, of course, not impossible), we will not be able to build such a functionality into the website. But we can offer open-ended questions as a feature for the learners to think further about the workshop’s contents. Perhaps they can be about an ethical aspect of the lesson?

Theory-to-Practice: revise discussion questions

The current questions center more on basic data and ethics:

  • What kind of data do you use in your research, and how do you acquire that data?
  • What questions do you have about your data? What kind of manipulations would you want to perform on that data?
  • What are the limitations of your data? Does your data suffice to show the full picture of your topic? What does it fail to capture?

Instead, add questions that review the major concepts from the workshop, such as variables, data types, functions, control flow, etc.

Move content from readme.md to frontmatter.md

  • Make sure you are in the right branch and have recently pulled all the content from the GitHub repository before you start working.

  • Create a frontmatter.md file in your repository
    Here, you can find the template for frontmatter.md. Copy the contents into a new file in your repository.

  • Finish the Abstract section
    Transfer over relevant portions from readme.md into the ## Abstract section in the frontmatter.md file.

  • Finish the Learning Objectives section
    Transfer over relevant portions from readme.md into the ## Learning Objectives section in the frontmatter.md file.

  • Check this one for free: the Estimated Time section
    Leave the ## Estimated Time section in the frontmatter.md file as it is (we will come back to this during our testing period).

  • Finish the Prerequisites section
    Think of prerequisites that will be important for learners to know in advance of this workshop that should go into the ## Prerequisites section in the frontmatter.md file.

  • Finish the Pre-reading suggestions section
    Think of/search for reading suggestions that could be good for learners to have read in advance of this workshop that should go into the ### Pre-reading suggestions section in the frontmatter.md file.

  • Finish the Projects that use these skills section
    Think of/search for projects that you know, which could be good for learners to look at in advance of this workshop that should go into the ### Projects that use these skills section in the frontmatter.md file.

  • Finish the Ethical Considerations section
    Think of ethical quandaries that could be good for learners to consider in advance of this workshop that should go into the ### Ethical Considerations section in the frontmatter.md file.

  • Finish the Resources section
    List any required installations, shortcut sheets, or other resources that can be helpful for learners to take care of/look at in advance of this workshop and add them into the ### Resources (optional) section in the frontmatter.md file.

  • Finish the Acknowledgements section
    List all the full names of every person who have worked on and contributed to this repository over the years in the ## Acknowledgements section in the frontmatter.md file. Each person should be added as a bullet point list.

Create and complete a lessons.md file

In Sprint 2, once again, we need your help moving content over from the old format into a new format. This time around we will do so in two steps:

  1. Copy-paste of content
    It doesn't sound very fun but it will be rewarding to go over the material once again and review the flow from one lesson to another.

    • Create a file lessons.md in the root of your repository. This will be the home of the entire lesson-flow.

    • For each of the lessons in the sections directory in your repository:

      • Remove any lines that contain "navigation bars" (eg. <<< Previous Next >>>)
      • Ensure that the first header is of level 1 (# ) and any following headers are level 2 (## ), and if there are nested headers under that, that they are consequential with the previous ones.
      • Once you've done that, copy the text from the section file, and
      • Paste the contents after the end of the lessons.md file.
  2. Once you have the whole flow set up in the lessons.md file, it is time to begin looking over the style and content of the entire body of the workshop:

    • Ensure that any multi-line code blocks are correctly encased in three after one another—```— feel free to also annotate whether the code is python, html, css or anything else by adding those terms after the triple backticks. (You can read more about this technique here)

      ` ` `css
      testing out code
      ` ` `

      (In this example I have used spaces between the backticks because otherwise the block would not render correctly here, so keep the backticks with no spaces in your real-world work.)

    • Inline code, commands, filenames, or keyboard shortcuts should also be surrounded by single backticks:

      As you can see above, the `=` sign lets you assign symbols like `x` and `y` to data.

      (This example comes from the python workshop. You can see it in action here)

    • Feel free to use bolding (**bolded**) and italicizing (_italicized_) where you see fit, but sparingly. If it clarifies your content, good. Just remember that they can be overwhelming.

    • Try to make sure each section ends with a question/challenge/problem that makes our learners act and think on their own. Here's how the formatting should look (keep the ## Challenge header even if yours isn't technically a "challenge"):

      ## Challenge
      
      Here is where I write the challenge as a regular paragraph.
      
      ## Solution
      
      Here is where I write the solution as a regular paragraph.
      
      ` ` `python
      print("In the challenge and/or the solution, you can, of course, use code blocks and styling too!")
      ` ` `

    You can see an example in the python workshop, and you can see what it will look like in production—albeit still very much under development at the end of this page.

    • Pay attention to images that are, or should be, present. Do you need more/newer screenshots? Are the existing ones too old, of a low resolution, blurry, unclear? Please provide (i.e. upload screenshots with clear names) in an images directory that you can create in the repository's root directory. Link them in your lessons.md file by using markdown:

      ![don't forget to describe your image for the alt text here](images/your-image-name.png)
    • As above, pay attention to where you think an animated gif or a screencast might be appropriate, and make a note of it in the text. You can either put a placeholder, or a comment using inline html comments:

      <!-- it would be good with a screencast/gif here -->
    • If you find images that have been borrowed from elsewhere and credits are missing, please try to make sure we have appropriate credits in the text inline, or immediately after the image. (Pro-tip: You can use Google image search to find sources for most files.)


Resources

Style example

lessons.md example from project-lab

Move IF/ELSE from Challenge to Body of Lesson 10

As is now, it will prevent folks who skip the challenge from going through it, preventing them to understand the logics behind it (which in turn gets in their way when they go through the Text Analysis workshop)

Central markdown files finalized

lessons.md

  • Accept any pending pull requests

  • Implement all the edits/requests that you have left from your colleagues.

  • Add any additional content you think is needed for version 2.0 _and open any other using the label in your repo

  • Ensure the length of each lesson is not too long
    each section (beginning with a level 1 heading [#]) should be no more than 3-4 paragraphs

  • Ensure temporal references and references to other workshops are removed (since learners will “attend” these workshops mostly asynchronously)

frontmatter.md

  • Finalize and streamline all sections

  • Ensure your abstract is no longer than ~100 words
    If you need/want them to be longer, you can create a new first section in lessons.md and put the longer version of the abstract there.

  • Resolve any "TBD" content.

  • Make sure collaborator lists are complete with roles and links
    see Di’s example but feel free to add links to people’s websites!

  • Ensure all Projects and Readings have "annotations"
    annotations = 1-2 sentences answering “Why is it important for our learners to read or expose themselves to these readings/projects”? For examples, see agenda doc

theory-to-practice.md

  • Finalize and streamline all sections

  • Resolve any "TBD" content.

  • Ensure all Projects, Readings, and Tutorials have "annotations"
    annotations = 1-2 sentences answering “Why is it important for our learners to read or expose themselves to these readings/projects”? For examples, see agenda doc

The issue that closes them all

Feel free to close this issue after you have pushed all of your local branch updates to your GitHub repo, so I can initiate a pull request to the v2.0 branch. (If you feel comfortable and interested in doing it yourself, you can do that as well, of course!)

This is the issue that closes out the v2.0 edits from you. Thank you so very much for all your hard work this summer!

Theory-to-Practice: add example project

Looking for another example for the "Projects That Use These Skills" section. Already have included the NEH impact index, which showcases Python for web dev (Flask) and scraping data.

I want this section to give a more well rounded sense of what can be done with Python. Is there an interesting (preferably scholarly or student) project that showcases data visualization with python? Will love to hear suggestions! Thank you.

on windows, specify anaconda prompt

Anaconda prompt supports visual studio code and git, so it's gonna be by far the easiest way for them to run their python files. (just remind them to us dir instead of ls)

lessons.md reviewed

  • Look at your workshop on the website to see what your workshop currently looks like, and what looks like it needs to change.
  • Think about order and transitions—do the lessons follow a logical pattern and is it working? Do you need to add something somewhere? Are the transitions between the lessons clear?
  • Can you add a challenge at the end of the lesson that summarizes what the learner has learned, and activates the knowledge in an interactive way.
  • Think about the length of the lessons — are they too long? Too short? In general, each lesson should cover one topic, or one particular skill — or perhaps connect two skills. If you find that you’re covering more than that in one lesson, perhaps they should be split into more than one.
  • While reviewing the lessons.md file, think about vocabulary terms that we should add in an easily accessible "dictionary" for our learners.

Feel free to reach out to me and @lmrhody and ask for help, if you need it. Also feel free to involve others in the group!

Add one or more opening paragraph(s) in Theory to Practice section

We want to make sure that the theory-to-practice.md file is somewhat more useful welcoming than only a couple of bulletpoints, so this feature request concerns the end of your workshop.

Imagine the theory-to-practice.md file as a form of mentoring and consultation (or a step in that direction): What would you say at the end of your workshop to help think about how the skill the just learned could be refined and improved? Can you give the learner something more to go on than a bulleted list? Something that would entice them to stay on this page and choose to dig deeper into the skills/tools in your workshop?

Concrete step

Add one or more regular paragraph/s at the top of your theory-to-practice.md file (under the line that contains # Theory to Practice and before ## Suggested Further Readings). If you need, use formatting (** for bolding and _ for italics), and/or headings (but make sure to only use level 3 headings—###).

You can see an example here. If you have any questions, don't hesitate to tag @kallewesterling and comment below, or DM via Slack.

Add lesson goals at the start of each lesson

For future iteration, it would be helpful to add/reiterate the lesson goal in each section so that participants know what they are working towards in that particular section.

in loops.md fix code for printing 2nd item in list

Looks like we copied the same line for 2 items in the list.
when printing names of flowers using number in list, the second flower (violets) should use number 2, not one, no? Is this intentional so that they go back to fix it?

Create glossary term files from python

  • Go through lessons.md (and other files) and find all important terms in need of definition to help learners grasp concepts, tools, commands, etc. List the files in a text file, or keep them in this issue feed below, for instance.

  • Add a file to the glossary repository's terms folder called <term>.md for each of the terms.

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.