CSC 221: Introduction to Programming
Course Overview Fall 2018
- 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
overview & history: hardware vs. software, technology generations, ...
problem-solving skills, critical thinking skills, communication skills
SCRATCH PROGRAMMING
simple, visual introduction to programming concepts
actions (e.g., move), conditionals, loops, event-handlers, variables
simple object interaction via sensing and broadcasts
introduction to object-oriented concepts
sprites = objects, sprite properties = fields, script blocks = methods
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 statements, 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-else, elif (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, writing to a file, write
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, ...
list comprehensions
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
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)
counters & sums for collecting data
e.g., roll dice until doubles, count number of vowels, read file until done
String traversal/concatenation for manipulating text
e.g., construct acronym, encode a message, get avg word length
input for user input; read/readline/write 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, deal_card, add_card, num_cards, ...)
agile development
high-level (usually OO) design -> simplified prototype -> augment/revise
ASSIGNMENTS:
1. Programming concepts (in Scratch)
2. Python statements & modules (wins & time & monograms)
3. Functions (rewriting HW2 & volleyball simulations)
4. Strings & text files (rotating substitution cipher)
5. Files & lists (literary fingerprint)
6. Lists & data (tweet statistics)
7. Classes & OOP (interactive FullFlush game)