2nd Semester Intro to Computer Science

Do Now 2.02

Part 1

Open up the console. Type each line of the following code into the interactive editor:

 >>> 5 < 3
 >>> 5 > 3
 >>> type(5 < 3)
 >>> type(5 > 3)
 >>> my_favorite_animal = "cats"
 >>> user_favorite_animal = input("What is your favorite animal? ")
 >>> my_favorite_animal == user_favorite_animal

In your Notebook, answer the following

  1. What does 5 < 3 evaluate to?
  2. What is the type of 5 < 3? What does that stand for (should be familiar from Snap!)?
  3. What is the difference between == and = ?
  4. What data type do you think my_favorite_animal == user_favorite_animal is?

Part 2

Open up the console. Type the following code into the interactive editor.

 >>> months_with_driving_permit = 6
 >>> age = 16
 >>> can_get_license = months_with_driving_permit >= 6 and age >= 16
 >>> print(can_get_license)

In your Notebook, add this to your notes in your Notebook

  1. What does and do here? What type do you think can_get_license is?
  2. Update the code to fit the new driving law: If you are over the age of 18 you don’t need to have a permit

Part 3

Open up the console. Type the following code into the interactive editor.

>>> animal = 'mouse'
>>> animal == 'cat' or 'dog'

In your Notebook, continue to your answers in your Notebook to the following

  1. What does = and == do here?
  2. What is the difference between the to statements?

Part 4

Open up the console. Type the following code into the interactive editor.

>>> animal = 'mouse'
>>> animal == 'cat' or animal == 'dog'

In your Notebook, continue your notes in your Notebook

  1. What does = and == do here?
  2. What is the difference between the to statements here and Part 3 statements?

Edit this page Report an issue