Description
Introduction to Computer Science in Python course teaches the fundamentals of computer programming as well as some advanced features of the Python language. Students use what they learn in this course to build simple console-based games. This course is equivalent to a semester-long introductory Python course at the college level.
Prerequisites: Introduction to Computers, Javascript
Each unit of the course is broken down into lessons. Lessons consist of video tutorials, short quizzes, example programs to explore, and written programming exercises, adding up to over 100 hours of hands-on programming practice in total. Each unit ends with a comprehensive unit test that assesses student’s mastery of the material from that unit.
Units:
Unit 1: Introduction to Programming in Python
● Commands, ● Colors ● Loops ● Functions
Assignments / Labs
○ Draw simple shapes with different colors ○ Reduce redundancy in your program using loops and functions
Unit 2: Basic Python and Console Interaction
● Printing ● Debugging ● Variables ● Types ● Arithmetic expressions ● User input ● Converting input from a string
Assignments / Labs
■ Print messages to the console
○ Variables
■ Create variables of different types, and print them to the console.
○ Types
■ Investigate the types of different variables
■ Convert between types
○ Input/output, arithmetic expressions
■ Age in one year – ask the user how old they are, and tell them how old they will be in one year
■ Rectangle, part 1 – make variables for length and width and compute area and perimeter
■ Rectangle, part 2 – ask the user for length and width and compute area and perimeter
■ Quadratic formula – ask the user for the coefficients of a quadratic equation, and compute the solutions
Unit 3: Control Flow
Comments ● If statements ● Boolean values ● Logical operators ● Comparison operators ● Truth tables ● De Morgan’s Laws
● Short-circuit evaluation ● Floating point numbers and “equality” ● While loops ● For loops ● Nested control structures
● Functions ● Exceptions
○ If statements and boolean values
■ Is it raining? – Write a program that uses a boolean variable to determine whether or not it is raining
○ Boolean operators, and expressions
■ Boolean variable – take a variable and use it in an if statement
■ Old Enough to Vote? – user reports age and program tells them whether or not they can vote in the US
■ Transaction – user reports balance and deposit/withdrawal, and program prints new balance or error
■ Recipe – ask the user for ingredients, amounts per serving, and number of servings, and report the total amount of each ingredient needed
○ Loops
■ Average test score – compute the average of several test scores
■ Divisibility – ask the user to enter a numerator and denominator, and re-prompt until the denominator is non-zero
○ Functions
■ Raining cats and dogs – write functions to print text art of a cat and a dog
■ Temperature converter – write functions to convert from Fahrenheit to Celsius and vise versa
○ Exceptions
■ Temperature converter, part 2 – add exception handling to your temperature conversion program
○ Putting it all together
■ Enter a positive number – make a function to repeatedly ask the user to enter a number until they enter a positive number
Unit 4: Strings
● Indexing and slicing ● Math operators on strings ● For loops over a string ● String methods
Indexing
■ First character – write a function that takes a string and returns the first character
■ All but the first character – write a function that takes a string and returns everything but the first character
○ Math operators and strings
■ Full name – write a function that takes two strings (a first name and a last name) and returns a full name as a single string
■ Replace a letter – write a function that takes a string and returns a copy with the character at a particular index replaced with a dash
○ For loops on strings
■ Count occurrences – write a function that takes two strings and returns the number of times the second string appears in the first string
○ String methods
■ Enthusiasm – write a function that takes a string and returns that string in all upper case
■ Remove all from string – write a function that takes two strings and returns a string that consists of the first string with all instances
of the second string removed
Unit 5: Data Structures
● Tuples ● Lists ● Dictionaries ● 2D lists ● List comprehensions ● Packing and unpacking ● Mutable vs. immutable ● Equivalence vs. identity
Unit 6: Hangman Project
Allow students to combine a variety of topics (strings,loops, booleans, user input, etc.) in a single program
● Introduce students to incremental development
● Strengthen debugging skills by having students develop a larger project
● Testing
Unit 7: Classes and Objects
● Classes ● Attributes ● Class variables vs. instance variables ● Methods ● Built-in methods ● Composition, inheritance, and polymorphism
● Private attributes
Unit 8: Who Said It? Project
● File reading ● Allow students to combine a variety of topics in a single program
● Re-emphasize incremental development
● Strengthen debugging skills by having students develop a larger project
● Testing