CSC 221: Computer Programming I
- 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).
overview & history: hardware vs. software, technology generations, ...
problem-solving skills, critical thinking skills, communiation skills
simple, visual introduction to programming concepts
actions (e.g., move), conditionals, loops, event-handlers, variables
simple object interaction via sensing and broadcasts
sprites = objects, sprite properties = fields, script blocks = methods
PYTHON LANGUAGE FEATURES
basic data types: numbers, strings, Booleans
naming conventions, assignment statements, expressions
def, parameters, return statements, doc strings
built-in functions (print, abs, max, min), importing modules (random, math)
if statement, Boolean operators (<, <=, >, >=, ==, !=, and or, not)
if (1-way), if-else (2-way), cascading if-else, elif (multi-way)
for loops, counter/range-driven
while loops, condition-driven
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, Caesar cipher, Pig Latin
lists (sequences of arbitrary items, mutable)
methods: count, index, sort, append, extend, insert, remove, ...
examples: list of words, row of cards, 2-D grid of pixels
class definition, fields, methods, self
special methods: __init__, __str__
examples: Die, DeckOfCards, RowOfCards, Image
conditionals for alternatives
e.g., recognize doubles, recognize a vowel, distinguish Skip-3 commands
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, play until "quit"
String traversal/concatenation for manipulating text
e.g., construct acronym, encode a message, get avg word length
input/raw_input for user input; read/readline/write for files
e.g., interactive Skip-3, reading text from a file & splitting into words
lists for storing and accessing arbitrary data
e.g., words from a line of text, cards in a deck, pixels in an image
classes model real-world entities; objects are instances of those classes
fields maintain state of an object; methods implement behaviors
e.g., RowOfCards models a row of cards
field (list of cards), methods (addAtEnd, moveCard, numCards, ...)