CSC 221: Introduction to Programming
Course Overview Fall 2023
- To develop problem solving and programming skills to enable the student to design solutions to non-trivial problems and implement those solutions in Python.
- To master the fundamental programming constructs of Python, including variables, expressions, functions, control structures, and lists.
- To build a foundation for more advanced programming techniques, including object-oriented design and the use of standard data structures (as taught in CSC 222).
GENERAL KNOWLEDGE
problem-solving skills, critical thinking skills, communication skills
PYTHON LANGUAGE FEATURES
variables:
basic data types: numbers, strings, Booleans
naming conventions, assignment statements, expressions
immutable vs. mutable values, variable scope
functions
def, parameters, return statement, doc strings
built-in functions (print, abs, max, min), importing modules (random, math)
conditional execution
if statement, Boolean operators (<, <=, >, >=, ==, !=, and or, not)
if (1-way), if-else (2-way), cascading if-elif-else (multi-way)
repetition
for loops, counter/range-driven
while loops, condition-driven
input/output
input function, reading from a file, read vs. readline
print function
sequences
common operations/functions: +, *, len, indexing, slicing
traversal: by item, by index
strings (sequences of characters, immutable)
methods: isalpha, capitalize, upper, strip, find, replace, ...
examples: palindrome, rotation, cipher
lists (sequences of arbitrary items, mutable)
methods: count, index, sort, insert, remove, ...
examples: list of words, tweet data, letter counts, hand of cards
classes/objects
class definition, fields, methods, self
special methods: __init__, __str__, __eq__, __lt__, __le__
examples: Turtle, Die, Coin, Card, DeckOfCards, Image
PROGRAMMING TECHNIQUES
conditionals for alternatives
e.g., recognize doubles, recognize a vowel, distinguish flush/full house
loops for repetition (conditional while loops, range-driven for loops)
accumulator pattern for counting/adding/collecting data
e.g., roll dice until doubles, count number of vowels, construct acronym
input for user input; read/readline for files
e.g., interactive card game, reading text from a file & splitting into words
lists for storing and accessing arbitrary data
e.g., words from a line of text, tweet data, cards in a deck
object-oriented design
classes model real-world entities; objects are instances of those classes
fields maintain state of an object; methods implement behaviors
e.g., DeckOfCards
field (list of cards), methods (shuffle, dealCard, addCard, numCards, ...)
agile development
high-level (usually OO) design -> simplified prototype -> augment/revise
ASSIGNMENTS:
1. Python statements
2. Python modules (wheels-on-the-bus, baseball stat, relative time)
3. Python functions (rewriting HW2 & FaceOff game simulations)
4. Files & strings (author fingerprint v.1)
5. Files & lists (author fingerprint v.2 w/ letter histogram)
6. Lists & structured data (tweet statistics)
7. Classes & OOP (interactive Skip3 game)