Exam 2
Instructions are the same as previous exam. I suggest you review HW 5-8, reading quizzes 8-16, and activities 14 - 27. Topics include:
- strings (concatenation, repetition, index, length, slice, membership, justification, upper/lower-case,
find
, replace
, ord
, chr
, str
, formatting) and immutability
- encryption and decryption using transposition or substitution cipher
- prompting for user input with
input
function
- lists (initialization, indexing, concatenation, reptition, membership, length, slicing,
append
, insert
, pop
, sort
, reverse
, index
, count
, remove
, list comprehension) and mutability
- dictionaries (
keys
, values
, items
, get
, membership, index operator, del
)
- tuples (e.g., what is returned from dictionary
items
)
- read from / write to files
- read from URLs, 4 components of URL (protocol, host, resource, parameters), definition of HTML,
- while loops, definition of infinite loop,
- statistics: definition of dispertion, central tendency, mean, median, mode, frequency distribution, histogram,
min
and max
functions, Pearson correlation coefficient (the range and significance of value)
Exam 1
Overview
- definition of computer science and applications
- Python interpreter, Python prompt, shell vs. file editor
- comments
- primitive types: integers, floating point numbers, strings, booleans
- naming objects, assignment statements, variables, expressions, keywords
- mathematical operators:
+, -, *, /, //, %, **
- relational operators:
<, <=, >, >=, ==, !=
- logical operators:
and, or, not
- using modules and functions provided by Python
print
turtle
module: how to import, create turtle, use functions on turtle forward
, goto
, right
/left
, position
, dot
, penup
, pendown
math
module: how to import, use functions sqrt
, use constant pi
.
random
module: how to import, use function random
- constructor, dereferencing and dot operator
- functions (function signature, function definition, parameters, how to call/invoke a function, return)
for
loops, 3 ways to call range
, loop variable, accumulator pattern
- if statements (
if
, elif
, else
), nested if statements
- approximating pi (Archimedes, Leibniz, Wallis, Monte Carlo)
I suggest you review chapters 1 & 2 from our book, HW 1-4, and reading quizzes 1-7.
Our book and all in-class activities give you many examples that you can work through to practice.
You can also rewatch lecture videos for additional examples and explanations.
Instructions for Exam
- Once you start the exam, a timer will begin for 60 minutes and your work will automatically be submitted when the timer ends. That timer continues regardless of whether you have the tab open.
- The exam will be posted on Moodle. Do not take the exam in Teams. Use a web browser and open Moodle from there.
- You can start the exam any time beginning Monday 9/21 at 8am, but it is due by 11:59pm Monday 9/21. We will not meet for class that day so that you have time to take the exam.
- I will be available on Teams during our normal class time in the event of questions. I will not be available outside of our regular class time.
- I suggest you do the following BEFORE you start:
- plug in your laptop charger so you don’t lose battery
- check that your internet is working
- ensure you have 60 minutes of uninterrupted time
- Your score will be taken out of 50 points.
- It is open book and open notes, but you will not have time to consult your book/notes for all questions, so please study accordingly.
- It must be completed individually.
- Question format: all questions are worth 1-3 points depending on their level of difficulty and number of subproblems. Questions have the following form.
- Multiple choice / true false. For example,
- Given a few lines of code which manipulate a variable, what is the value of a variable after all lines are executed?
- What is a result of the expression
((True or False) and False)
?
- What is the python prompt?
- Matching. For example,
- Pick the appropriate definition/description corresponding to the terms function, selection statement, accumulator variable, and for loop.
- Rearrange lines of code correctly. For example,
- Given several lines of code that are out of order, put them in the correct order so that the given function computes the sum of the first N numbers.
- Fill-in. For example,
- What is the value of a variable after all lines are executed?
- Given the following lines of code which approximates Pi, what condition should be inside the if statement?
- Short responses. For example,
- Write a function that uses a for loop to compute and returns the sum of the first 10 even numbers (2+4+….+18+20).
- Describe what a given function does.
- Describe the difference between
==
and =
- Write a function that returns true if a number is even.