In [1]:
# Run this cell to set up packages for lecture.
from lec07_part_1_imports import *

Lecture 7 – Conditional Statements and Iteration¶

DSC 10, Summer 2025¶

Agenda¶

  • Booleans.
  • Conditional statements (i.e. if-statements).
  • Iteration (i.e. for-loops).

Note:

  • We've finished introducing new DataFrame manipulation techniques.
  • Today we'll cover some foundational programming tools, which will be very relevant as we start to cover more ideas in statistics in the second half of the class.

Booleans¶

Recap: Booleans¶

  • bool is a data type in Python, just like int, float, and str.
    • It stands for "Boolean", named after George Boole, an early mathematician.
  • There are only two possible Boolean values: True or False.
    • Yes or no.
    • On or off.
    • 1 or 0.
  • Comparisons result in Boolean values.
In [2]:
dept = 'DSC'
course = 10
In [3]:
course <=20
Out[3]:
True
In [4]:
type(course < 20)
Out[4]:
bool

The in operator¶

Sometimes, we'll want to check if a particular element is in a list/array, or a particular substring is in a string. The in operator can do this for us, and it also results in a Boolean value.

In [5]:
course in [10, 20, 30]
Out[5]:
True
In [6]:
'DS' in dept
Out[6]:
True
In [7]:
'DS' in 'Data Science'
Out[7]:
False

Boolean operators; not¶

There are three operators that allow us to perform arithmetic with Booleans – not, and, and or.

not flips True ↔️ False.

In [8]:
dept == 'EE'
Out[8]:
False
In [9]:
not dept == 'EE'
Out[9]:
True
In [10]:
a = 2
print(not a == 3)
print (a != 3)
True
True

The and operator¶

The and operator is placed between two bools. It is True if both are True; otherwise, it's False.

In [11]:
80 < 30 and course < 20
Out[11]:
False
In [12]:
80 > 30 and course < 20
Out[12]:
True

The or operator¶

The or operator is placed between two bools. It is True if at least one is True; otherwise, it's False.

In [13]:
course in [10, 20, 30, 80] or type(course) == str
Out[13]:
True
In [14]:
# Both are True!
course in [10, 20, 30, 80] or type(course) == int
Out[14]:
True
In [15]:
# Both are False!
course == 80 or type(course) == str
Out[15]:
False

Order of operations¶

  • By default, the order of operations is not, and, or. See the precedence of all operators in Python here.
  • As usual, use (parentheses) to make expressions more clear.
In [16]:
course == 10 or (dept == 'DSC' and dept == 'CSE')
Out[16]:
True
In [17]:
# Different meaning!
((course == 10 or dept == 'DSC') and dept == 'EE') and dept == 'CSE'
Out[17]:
False
In [18]:
# With no parentheses, "and" has precedence.
course == 10 or dept == 'DSC' and dept == 'CSE'
Out[18]:
True

Note: & and | vs. and and or¶

  • Use the & and | operators between two Series. Arithmetic will be done element-wise (separately for each row).
    • This is relevant when writing DataFrame queries, e.g. courses[(courses.get('dept') == 'DSC') & (courses.get('course') == 10)].
  • Use the and and or operators between two individual Booleans.
    • e.g. dept == 'DSC' and course == 10.

Conditionals¶

if-statements¶

  • Often, we'll want to run a block of code only if a particular conditional expression is True.
  • The syntax for this is as follows (don't forget the colon!):
if <condition>:
    <body>
        
  • Indentation matters!
In [19]:
capstone = 'finished'
capstone
Out[19]:
'finished'
In [20]:
if capstone == 'finished':
    print('Looks like you are ready to graduate!')
Looks like you are ready to graduate!
In [21]:
singer = 'Arctic Monkeys'
song = 'Do I wanna know'
if 'Arctic' in singer and 'Hello' in song:
    print('I want to listen to this song')

else¶

If you want to do something else if the specified condition is False, use the else keyword.

In [22]:
capstone = 'finished'
capstone
Out[22]:
'finished'
In [23]:
if not capstone == 'finished':
    print('Looks like you are ready to graduate!')
else:
    print('Before you graduate, you need to finish your capstone project.')
Before you graduate, you need to finish your capstone project.

elif¶

  • What if we want to check more than one condition? Use elif.
  • elif: if the specified condition is False, check the next condition.
  • If that condition is False, check the next condition, and so on, until we see a True condition.
    • After seeing a True condition, it evaluates the indented code and stops.
  • If none of the conditions are True, the else body is run.
In [24]:
capstone = 'in progress'
units = 123

if capstone == 'finished' and units >= 180:
    print('Looks like you are ready to graduate!')
elif units < 180:
    print('Before you graduate, you need to finish your capstone project.')
elif capstone != 'finished' and units < 180:
    print('Before you graduate, you need to finish your capstone project and take', 
          180 - units, 'more units.')
elif units < 180:
    print('Before you graduate, you need to finish your capstone project.')
else:
    print('Before you graduate, you need to take', 180 - units, 'more units.')
Before you graduate, you need to finish your capstone project.

What if we use if instead of elif?

In [25]:
if capstone == 'finished' and units >= 180:
    print('Looks like you are ready to graduate!')
if capstone != 'finished' and units < 180:
    print('Before you graduate, you need to finish your capstone project and take',
          180 - units, 'more units.')
else:
    print("hello")
if units >= 180:
    print('Before you graduate, you need to finish your capstone project.')
else:
    print('Before you graduate, you need to take', 180 - units, 'more units.')
Before you graduate, you need to finish your capstone project and take 57 more units.
Before you graduate, you need to take 57 more units.

Example: Percentage to letter grade¶

Below, complete the implementation of the function, grade_converter, which takes in a percentage grade (grade) and returns the corresponding letter grade, according to this table:

Letter Range
A [90, 100]
B [80, 90)
C [70, 80)
D [60, 70)

| F | [0, 60)

Your function should work on these examples:

>>> grade_converter(84)
'B'

>>> grade_converter(60)
'D'

✅ Click here to see the solution after you've tried it yourself.
def grade_converter(grade):
    if grade >= 90:
        return 'A'
    elif grade >= 80:
        return 'B'
    elif grade >= 70:
        return 'C'
    elif grade >= 60:
        return 'D'
    else:
        return 'F'
In [26]:
def grade_converter(grade):
    if 90 <= grade and grade <= 100:
        return 'A'
    elif 80 <= grade and grade < 90:
        return 'B'
    elif 70 <= grade and grade < 80:
        return 'C'
    return 'F'
In [27]:
grade_converter(65)
Out[27]:
'F'
In [28]:
grade_converter(84)
Out[28]:
'B'
In [29]:
grade_converter(60)
Out[29]:
'F'

Extra Practice¶

def mystery(a, b):
    if (a + b > 4) and (b > 0):
        return 'bear'
    elif (a * b >= 4) or (b < 0):
        return 'triton'
    else:
        return 'bruin'

Without running code:

  1. What does mystery(2, 2) return?
  2. Find inputs so that calling mystery will produce 'bruin'.
In [30]:
def mystery(a, b):
    if (a + b > 4) and (b > 0):
        return 'bear'
    elif (a * b >= 4) or (b < 0):
        return 'triton'
    else:
        return 'bruin'
In [ ]:
 
In [ ]:
 

Iteration¶

No description has been provided for this image

for-loops¶

In [31]:
import time

print('Launching in...')

for x in [10, 8, 6, 4, 2]:
    print('t-minus', x)
    time.sleep(0.5) # Pauses for half a second.
    
print('Blast off! 🚀')
Launching in...
t-minus 10
t-minus 8
t-minus 6
t-minus 4
t-minus 2
Blast off! 🚀

for-loops¶

  • Loops allow us to repeat the execution of code. There are two types of loops in Python; the for-loop is one of them.
  • The syntax of a for-loop is as follows:
for <element> in <sequence>:
    <for body>
  • Read this as: "for each element of this sequence, repeat this code."
    • Lists, arrays, and strings are all examples of sequences.
  • Like with if-statements, indentation matters!

Activity¶

Using the array colleges, write a for-loop that prints:

Revelle College
John Muir College
Thurgood Marshall College
Earl Warren College
Eleanor Roosevelt College
Sixth College
Seventh College
Eighth College

✅ Click here to see the solution after you've tried it yourself.
for college in colleges:
    print(college + ' College')
In [32]:
colleges = np.array(['Revelle', 'John Muir', 'Thurgood Marshall', 
            'Earl Warren', 'Eleanor Roosevelt', 'Sixth', 'Seventh', 'Eighth'])
In [33]:
for c in colleges:
    print(c)
Revelle
John Muir
Thurgood Marshall
Earl Warren
Eleanor Roosevelt
Sixth
Seventh
Eighth

Example: Multiplication Table¶

  • We know how to print the first row of the 12x12 multiplication table, using the multiples function we wrote earlier.
In [34]:
def multiples(k):
    '''This function returns the 
    first twelve multiples of k.'''
    return np.arange(k, 13*k, k)

print(multiples(1))
[ 1  2  3  4  5  6  7  8  9 10 11 12]
  • Similarly, we would print the second row with print(multiples(2)), and the third row with print(multiples(1)) and so on.
  • We can condense all these print statements with a for-loop!
In [35]:
for i in np.arange(1, 13):
    print(multiples(i))
[ 1  2  3  4  5  6  7  8  9 10 11 12]
[ 2  4  6  8 10 12 14 16 18 20 22 24]
[ 3  6  9 12 15 18 21 24 27 30 33 36]
[ 4  8 12 16 20 24 28 32 36 40 44 48]
[ 5 10 15 20 25 30 35 40 45 50 55 60]
[ 6 12 18 24 30 36 42 48 54 60 66 72]
[ 7 14 21 28 35 42 49 56 63 70 77 84]
[ 8 16 24 32 40 48 56 64 72 80 88 96]
[  9  18  27  36  45  54  63  72  81  90  99 108]
[ 10  20  30  40  50  60  70  80  90 100 110 120]
[ 11  22  33  44  55  66  77  88  99 110 121 132]
[ 12  24  36  48  60  72  84  96 108 120 132 144]
  • The line print(multiples(i)) is run thirteen times:
    • On the first iteration, i is 1.
    • On the second iteration, i is 2.
    • On the third iteration, i is 3.
  • This happens, even though there is no assignment statement i = anywhere.
  • Finally, we add some tabs and other formatting for a nicer-looking multiplication table!
In [36]:
print("\t 1\t2\t3\t4\t5\t6\t7\t8\t9\t10\t11\t12")
print("_"*100)
for i in np.arange(1, 13):
    print(str(i)+"\t|"+"\t".join(multiples(i).astype(str)))
	 1	2	3	4	5	6	7	8	9	10	11	12
____________________________________________________________________________________________________
1	|1	2	3	4	5	6	7	8	9	10	11	12
2	|2	4	6	8	10	12	14	16	18	20	22	24
3	|3	6	9	12	15	18	21	24	27	30	33	36
4	|4	8	12	16	20	24	28	32	36	40	44	48
5	|5	10	15	20	25	30	35	40	45	50	55	60
6	|6	12	18	24	30	36	42	48	54	60	66	72
7	|7	14	21	28	35	42	49	56	63	70	77	84
8	|8	16	24	32	40	48	56	64	72	80	88	96
9	|9	18	27	36	45	54	63	72	81	90	99	108
10	|10	20	30	40	50	60	70	80	90	100	110	120
11	|11	22	33	44	55	66	77	88	99	110	121	132
12	|12	24	36	48	60	72	84	96	108	120	132	144

Ranges¶

  • Recall, each element of a list/array has a numerical position.
    • The position of the first element is 0, the position of the second element is 1, etc.
  • We can write a for-loop that accesses each element in an array by using its position.
  • np.arange will come in handy.
In [37]:
np.arange(100)
Out[37]:
array([ 0,  1,  2, ..., 97, 98, 99])
In [38]:
actions = np.array(['ate', 'slept', 'ran'])
feelings = np.array(['content 🙂', 'energized 😃', 'exhausted 😓'])
In [39]:
len(actions)
Out[39]:
3
In [40]:
for i in np.arange(len(actions)):
    print(i)
0
1
2
In [41]:
for i in np.arange(len(actions)):
    print('I', actions[i], 'and I felt', feelings[i])
I ate and I felt content 🙂
I slept and I felt energized 😃
I ran and I felt exhausted 😓

Example: Goldilocks and the Three Bears¶

We don't have to use the loop variable inside the loop!

In [42]:
for i in np.arange(3):
    print('🐻')
print('👧🏼')
🐻
🐻
🐻
👧🏼

Randomization and iteration¶

  • In the next few lectures, we'll learn how to simulate random events, like flipping a coin.
  • Often, we will:
    1. Run an experiment, e.g. "flip 10 coins."
    2. Compute some statistic, e.g. "number of heads," and write it down somewhere.
    3. Repeat steps 1 and 2 many, many times using a for-loop.
No description has been provided for this image

np.append¶

  • This function takes two inputs:
    • An array.
    • An element to add on to the end of the array.
  • It returns a new array. It does not modify the input array.
  • We typically use it like this to extend an array by one element:
name_of_array = np.append(name_of_array, element_to_add)
  • ⚠️ Remember to store the result!
In [43]:
some_array = np.array([])
some_array
Out[43]:
array([], dtype=float64)
In [44]:
np.append(some_array, 'hello')
Out[44]:
array(['hello'], dtype='<U32')
In [45]:
some_array
Out[45]:
array([], dtype=float64)
In [46]:
# Need to save the new array!
some_array = np.append(some_array, 'hello')
some_array
Out[46]:
array(['hello'], dtype='<U32')
In [47]:
some_array = np.append(some_array, 'there')
some_array
Out[47]:
array(['hello', 'there'], dtype='<U32')
In [48]:
lst_a = []
lst_b = [1, 2, 3]
for i in range(len(lst_b)):
    lst_a.append(lst_b[i])
In [49]:
np.array(lst_a)
Out[49]:
array([1, 2, 3])

Example: Coin flipping¶

The function flip(n) flips n fair coins and returns the number of heads it saw. (Don't worry about how it works for now.)

In [50]:
def flip(n):
    '''Returns the number of heads in n simulated coin flips, using randomness.'''
    return np.random.multinomial(n, [0.5, 0.5])[0]
In [51]:
# Run this cell a few times – you'll see different results!
flip(10)
Out[51]:
5

Let's repeat the act of flipping 10 coins, 10000 times.

  • Each time, we'll use the flip function to flip 10 coins and compute the number of heads we saw.
  • We'll store these numbers in an array, heads_array.
  • Every time we use our flip function to flip 10 coins, we'll add an element to the end of heads_array.
In [52]:
# heads_array starts empty – before the simulation, we haven't flipped any coins!
heads_array = np.array([])

for i in np.arange(10000):
    
    # Flip 10 coins and count the number of heads.
    num_heads = flip(10)
    
    # Add the number of heads seen to heads_array.
    heads_array = np.append(heads_array, num_heads)
In [53]:
heads_lst = []
for i in np.arange(10000):
    num_heads = flip(10)
    heads_lst.append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,
 7,
 6,
 6,
 4,
 7,
 4,
 6,
 7,
 5,
 1,
 5,
 6,
 4,
 6,
 5,
 6,
 7,
 5,
 8,
 7,
 6,
 6,
 8,
 5,
 6,
 7,
 3,
 4,
 7,
 5,
 6,
 6,
 6,
 4,
 5,
 6,
 5,
 6,
 5,
 4,
 5,
 5,
 6,
 5,
 5,
 6,
 5,
 2,
 4,
 4,
 5,
 5,
 6,
 4,
 7,
 8,
 6,
 8,
 5,
 5,
 4,
 4,
 8,
 6,
 6,
 ...]

Now, heads_array contains 10000 numbers, each corresponding to the number of heads in 10 simulated coin flips.

In [55]:
heads_array
Out[55]:
array([6., 5., 5., ..., 8., 5., 3.])
In [56]:
len(heads_array)
Out[56]:
10000
In [57]:
(bpd.DataFrame().assign(num_heads=heads_array)
 .plot(kind='hist', density=True, bins=np.arange(0, 12), ec='w', legend=False, 
       title = 'Distribution of the number of heads in 10 coin flips')
);
No description has been provided for this image
No description has been provided for this image

The accumulator pattern¶

  • To store our results, we'll typically use an int or an array.
  • If using an int, we define an int variable (usually to 0) before the loop, then use + to add to it inside the loop.
    • Think of this like using a tally.
  • If using an array, we create an array (usually empty) before the loop, then use np.append to add to it inside the loop.
    • Think of this like writing the results on a piece of paper.
  • This pattern – of repeatedly adding to an int or an array – is called the accumulator pattern.

for-loops in DSC 10¶

  • Almost every for-loop in DSC 10 will use the accumulator pattern.

  • Do not use for-loops to perform mathematical operations on every element of an array or Series.

    • Instead use DataFrame manipulations and built-in array or Series methods.
  • Helpful video 🎥: For Loops (and when not to use them) in DSC 10.