Lecture 2: Introduction to programmingΒΆ

Based on the lecture and the readings (R&S Programming Basics) you should be able to:

  • Identify how variable values are set in a python program

  • Distinguish between numbers, strings, and booleans

  • Describe None

  • Understand how arithmetic works on both numbers and strings

Below, please find some practice problems for this topic. These problems should be completed by hand, that is, without the use of a computer. (Note: you can check your answer using ipython3.)

  1. Determine the value of b at the end of this code fragment:

a = 11
a = a/2 + a%2 + a//2
b = a
  1. Determine the value of e at the end of this code fragment:

c = True
d = False
c = c or d
e = c and d
f = not e
  1. Determine the value of i at the end of this code fragment:

f = 'abcde'
g = 7.0
h = str(g)
i = h + f
i = i + f