Fundamentals (Need) Exercises

Exercise 1 (Total recall?)

  1. Purely from memory, list as many of the basic Python features I mentioned in my notes as you remember.
    Use a Markdown cell for this list.
  2. Now, visit the notes and complete the list with the ones you missed.
    Indicate those you missed by putting them in italics.

Exercise 2 (Debug me)

Fix (debug) the following code to create a Pythagorean triple 3, 4, 5 (because \(3^2+4^2=5^2\)).

x, y = 3, 4
        z = sqrt(x*2 + y**2)
    Print(x, y, z)

Exercise 3 (In your own words)

Using your own words, write a single sentence to describe what each of the following means or the role they serve in Python.

Please use a Markdown table for this.

# Term Description
1 Function
2 Arguments
3 Comments
4 Indentations
5 Packages
6 .
7 :
8 []
9 [[[]]]
10 {}

Exercise 4 (More than one way to divide)

Programming languages usually offer multiple options for dividing one number by another. Shown below are three such options. Either by observation (i.e., trial and error), Googling or discussing with a friend, figure out what each one does.
I recommended the trial and error approach first so that you get a feel for how to use Python.
Indicate your answer by writing a comment.

5/2           # What do I do?
5//2          # What do I do?
5%2           # What do I do?
Back to top