Skip to content

Sep 04: Prac1, if-else Statements

Learning Objectives

After today's class, you should be able to:

  • Explain the logistics for taking a quiz in CS 149.
  • Evaluate boolean expressions with comparison operators (<, >, <=, >=, ==, !=).
  • Evaluate boolean expressions that involve comparisons with and, or, and not.

Reminders

  • Upcoming events
    • CS Dept Club Mixer – Thursday 9/4 at 5:00pm in King 259 + 260
    • Professional Resources – Friday 9/5 at 4:00pm in King Hall 259
  • Read Week 3 Reading and Activities – ideally:
    • 1st half before Friday
    • 2nd half before Monday
  • Submit HW 3 – ideally:
    • 1 and 2 before Friday
    • 3 and 4 before Monday

HW2 Debrief

[10 min]

Some highlights:

  • Splitting up long lines of code
  • Rounding to n decimal places
  • Using math module functions
  • // and % usually go together

Practice Quiz 1

[25 min]

Instructions:

This a timed quiz. You will have 25 minutes to complete. The quiz is on paper. Please write neatly so that your answers can be accurately graded. Remember to write your name at the top of the page.

MiniLecture

POGIL Activity

  • Conditions and Logic
    • If you are absent today, complete this activity at home
    • Bring your completed activity to class or office hours

Example Code

Model 1

type(True)
type(true)
type(3 < 4)
print(3 < 4)
three = 3
four = 4
print(three == four)
check = three > four
print(check)
type(check)
print(three = four)
three = four
print(three == four)

Model 2

a = 3
b = 4
c = 5

print(a < b and b < c)
print(a < b or b < c)
print(a < b and b > c)
print(a < b or b > c)
print(not a < b)
print(a > b or not a > c and b > c)