Be-A-Computer: Programming Basics

The purpose of these problems is to allow you to test your understanding of basic programming concepts. They should not take more than an hour to complete.

You should do these warm-up exercises by hand. We provide files that will allow you to check your answers.

To get started, run git pull upstream master to make sure you have the latest files. You can check your answers by running the Python program basics.py in pp/bac/

Basic Concepts

You can check your answers by running the Python program basics.py in bac1-3

Warm-up exercise #1: What is the value of w after evaluating the following code?

x = 7
y = 5.0
z = 10.0
w = x % 2 + y / z + z + y / (z + z)

Warm-up exercise #2: What is the value of c after evaluating the following code?

c = True
d = False
c = c and d
c = not c or d

Warm-up exercise #3: What is the output generated by the following program?

d = 0
for p in range(0, 5):
    if p % 4 == 0:
        d = d + (p-1) * 25;
    else:
        d = d + 100;
print("$" + str(d//100) + "." + str(d % 100))