CSC 221: Introduction to Programming
Fall 2023

Test 1 Review


Mon, Sep 25
9:00-10:45
  • The test will be conducted in-class (Eppley 110) via Blueline.
  • You are required to bring a laptop or use one of the lab machines.
  • The test is closed-book and closed-notes.
  • You have the full 105 minutes but shouldn't need it.
  • The test will include 52 points, but graded on a scale of 50. (Mistakes Happen!)
Types of questions
  • factual knowledge: TRUE/FALSE, multiple choice
  • conceptual understanding: short answer, discussion
  • synthesis and application: explain/debug code, trace/modify code

    There is a practice test in BlueLine with examples of each type of question.

Study advice
  • review online lecture notes
  • review online text (if not mentioned in class, won't be on test)
  • look over quizzes, homework assignments
  • reference other sources for examples, different perspectives
Course material Overview algorithm: a step-by-step sequence of instructions to carry out some task programming: the process of designing, writing, testing and debugging algorithms that can be carried out by a computer programs are tools for solving problems e.g., solving Sudoku puzzles, disease vector modeling, hailstone sequence Python is a simple but powerful (and widely used) language invented in 1991 by Guido von Rossum Variables, statements & expressions Python interpreter, book examples, IDLE shell data types numbers (int, float): +, -, *, /, //, **, % strings: + Booleans (True, False) variables variable names, naming conventions, reserved words assignment statements, expressions built-in functions type, max, min, abs, round, str, int, float, bool print: mixing text and variables, separating spaces input: prompt message, converting input to a number Debugging syntax vs. runtime vs. logic errors strategies create test cases with known outcomes utilize diagnostic print statement to isolate errors integrate testing with code development Functions predefined modules, import statement random: random, randint, choice math: sqrt, floor, ceil, nan, ... turtle: forward, left, right, color, ... for loop counter-driven repetition utilizes loop variable & range function examples: building a random string, turtle polygons user-defined functions a function defines a unit of computational abstraction can have inputs: parameters, default values, optional types can have output: return statement document using doc strings, displayed by help function user-defined modules metric: inchesToCentimeters, centimetersToInches, feetToMeters, metersToFeet, ... casino: rollDie, rollDice, flipCoin, pickCard Conditional execution if statement, optional else case Boolean operators: <, <=, >, >=, ==, != logical connectives: and or, not precedence rules, short-circuit evaluation cascading if-else statement using elif provides for multiway conditionals Repetition counter-driven vs. logic-driven loops for loops accessing the loop variable, adjusting the range examples: summing dice rolls, counting doubles while loops repetition is based on a Boolean test beware of black holes (infinite loops) examples: summing numbers in a range, hailstone sequence, listener loop, input validation extended example: Pig game simulations