Codelab / Chapter 05

Introduction to Python

[Back to Codelab index]

https://media.giphy.com/media/9xaryfkdWqqiK6QHKf/giphy.gif

Lesson

Lesson document

  1. A brief note about learning with AI
  2. Let’s get coding
  3. Python interactive interpreter
  4. Data structures
  5. Documentation
  6. Dogs

Resources

Python data types cheatsheet

Terms


Homework

Coding Assignment 0: Simplified Pig Latin

Produce a simple program to accept a single word as text input and then print out the pig latin translation.

Pig Latin is… more complicated and potentially more ambiguous than I thought when I first made this assignment. Because of this, we should start by implementing the simplest case for the word provided: just shift the first letter to the end and add “ay” to it.

Taking into consideration words starting with consonant clusters or vowels requires some conditional logic, which we haven’t learned yet, but feel free to jump ahead if you really want to show off.

So, input “dog” should print “ogday”, “Shane” should print “haneSay”, and “ogopogo” should print “gopogooay”.

Your code should be structured something like this:

word = input("Enter word: ")
# Pig latin code goes here
print(pig_latin)

Natural Language Coding

Once again, let’s write, in plain English, precise and detailed step-by-step instructions for a task: given a list of students, pair off each student with a partner, making sure to not double-book anyone and to not assign anyone to be their own partner. What kinds of “edge cases” (unexpected conditions) do we have to watch out for? What’s missing from these instructions?

Read:

Posner, Miriam (2015), Humanities Data, a Necessary Contradiction