Getting Started ¶
Haven’t touched Python before? No problem! Here’s a suggested sequence to get started:
- Start with Hedy, a very gentle introduction to Python programming.
- Then go through futurecoder.
- Then do Kaggle’s Python and pandas tutorials.
How to Succeed in This Class ¶
A word to the wise: Starting early is essential to success in programming. Newcomers sometimes think that they can start an assignment at the last minute and do reasonably well. Programming isn’t like writing a paper, where you can have partially developed arguments and missing information but still have something to submit. In programming, it often either works or it doesn’t. Most programming problems at this level require several rounds of trying and taking a break.
- Come to:
- class
- lab
- study sessions.
- office hours.
- Use
- Piazza.
- CodeHelp.
- Practice helpful habits:
- Don’t just “get it working”; understand why it works.
- Start early; take frequent breaks.
- Take small steps (Run your code frequently).
- Try doing lab and homework exercises again without looking at your prior solutions.
- Review what we did in class (e.g., POGIL, slides, Socrative quizzes). Try the exercises again.
- Discuss with a friend or classmate why something worked or didn’t work.
- Make your own cheat-sheet of syntax and concepts you’ve learned
- Review feedback from quizzes and assignments.
Extra Practice ¶
If you want more practice, here are some suggestions:
- Do the “Challenge” exercises in the textbook.
- Work through some Python practice problems.
- Here’s some more Python practice problems that I’m working on writing.
- Search for “Python practice” on your favorite search engine.
Patterns ¶
Gather, compute, use. Example:
# Gather
n = int(input("Enter a number: "))
# Compute
result = n * 2
# Use
print("Twice", n, "is", result)
Problem-Solving Strategies ¶
Once, twice, many ¶
A loop-writing strategy.
- Once: Write a program that does the right thing but only if there is exactly one of something.
- Twice: Extend the program so that it does the right thing if there are exactly two of something.
- Many: First, adapt the code so that “twice” is two copies of exactly the same lines of code. Then, surround that code with a loop that repeats the code as many times as needed.
Example: Sum the numbers in a list.
Once: Write a program that sums the numbers in a list of length 1.
numbers = [5]
total = numbers[0]
print("The sum is", total)
Twice: Extend the program so that it sums the numbers in a list of length 2.
numbers = [5, 7]
total = numbers[0] + numbers[1]
print("The sum is", total)
Many: First, adapt the code so that “twice” is two copies of exactly the same lines of code.
numbers = [5, 7]
total = 0
total = total + numbers[0]
total = total + numbers[1]
print("The sum is", total)
Then, surround that code with a loop that repeats the code as many times as needed.
numbers = [5, 7, 3, 8]
total = 0
for n in numbers:
total = total + n
print("The sum is", total)
Other Resources ¶
Paid courses ¶
Tools ¶
Other interesting things ¶
- Falsehoods Programmers Believe About Names
- How
ints andfloats (and other binary numbers) work:- an interactive tutorial
- simple and interactive: float.exposed and integer.exposed
- a very comprehensive reference