Unit 1: Programming Basics

Quiz 2 Review

You will be taking the second quiz on paper, individually, in class on February 15. It is closed-book, closed-notes, and closed-computer.### Scientific Context: Iteration

The quiz will cover all Python concepts covered in Lessons 1-6, including:

  • writing functions with multiple parameters and multiple return values
  • writing boolean expressions
  • type-casting
  • if-statements
  • for-loops
  • lists
  • while-loops

Pre-Activity Questions

You should consider doing this entire pre-activity without running the code in a Pyton code cell, to better duplicate your experience on the quiz.

1. Identify (1) the value of the variable x and (2) the result of type(x) after each command:

1a. x = 5.0*int(2)

1b. x = 3 == 5

2. Suppose grade is a variable that has been given a numeric value. Write a multibranch if-else statement that prints the word Great if grade is greater than 85, prints Help! if grade is less that 70, and prints Passing if grade is any other number. You do not need to write a function, just the if-else statement.

3. Write a Python for-loop to print out the numbers:
0
2
4
6
8
10

4. Write a Python while-loop to print out the numbers:
10
20
30
40
50


In [ ]: