Introduction to Computer Programming

In this course, trainees that have little or no prior experience with computer programming acquire the necessary programming background to be in a position to master any programming language that they choose to learn.

Course Description

Computer programming is something that can be learned, the same as reading, writing or playing a musical instrument. In fact it’s simpler than that. About 90% of computer programming  is planning, problem solving, and perseverance. Only 10% is about mastering a concrete programming language such as Python, C/C++ or Java. This course will teach trainees the 90%. At the end trainees will have acquired the mindset and skills of a successful programmer. Trainees will be ready to learn any advanced programming language quickly.

This course provides an introduction to programming, using Karel the Robot as trainees’ guide. (Karel the Robot is a legendary programming language originally introduced by the Stanford University professor Richard E. Pattis in his famous book Karel the Robot: A Gentle Introduction to the Art of Programming in 1981.) R.E. Pattis created Karel because his students lacked logic and problem-solving skills. Without these skills, one cannot be successful at computer programming.

Recommended Background

The only background trainees require for this course is a desire to learn how to program.

Equipment Requirements

Internet access

Email

One of the following browsers:

  • Google Chrome
  • Mozilla Firefox
  • Microsoft Internet Explorer (9.0 or above)
  • Safari

Course Structure and Length

This course is self-paced, and trainees will practice each skill and concept as they go.  Automatic feedback is built into the course for both practices and quizzes.

The course is divided into five Units, and each Unit is composed of five Sections. Each Section consists of 7 instructional/practice levels, a quiz, and a master (proficiency) level. Trainees can return to any level or quiz for review.

This table illustrates the course structure as units, sections, and levels.

Trainees will need approximately 80-120 hours, based on their ability level, to complete this course. Since the course is self-paced, the amount of time required to complete the course will vary from trainee to trainee. Trainees are responsible for learning both the tutorial content and the skills acquired through practice.

Unit 1

Section 1 (Getting Started)

  • Understand the function of the commands “go”, “left”, “right”, “get”, “put” by pressing buttons
  • Read task descriptions and understand game objectives
  • Plan ahead before implementing a solution
  • Practice logic while solving puzzles

Section 2 (Typing Code)

  • Type basic commands
  • Understand basic syntax rules:
    • Type one command per line
    • All commands must start at the beginning of the line
  • Syntax similarity to Python
  • Understand error messages
  • Multiple programs can solve a given task

Section 3 (Counting Loop I)

  • Keyword “repeat”
  • Repeat one command
  • Body of the loop, indentation
  • Identify the number of repetitions
  • Repeat multiple commands

Section 4 (Counting Loop II)

  • Identify repeating patterns that include sequences of commands
  • Use additional operations before the repeat loop
  • Use additional operations after a repeat loop
  • Use additional operations before and after a repeat loop
  • Use multiple consecutive repeat loops

Section 5 (Counting Loop III)

  • Identify repeating patterns that combine sequences of commands with multiple repeat loops
  • Use nested loops

Unit 2

Section 6 (Conditions I)

  • The if-statement, indentation
  • Combine if-statement and repeat loops in simple settings

Section 7 (Conditions II)

  • Combine if-statement and repeat loops in complex settings
  • Detect various obstacles, collectible objects and containers
  • Check if robot faces North
  • Keyword “else”
  • Keyword “not”
  • Keyword “pass”

Section 8 (Conditions III)

  • Combine multiple conditions
  • Combine conditions and nested loops
  • Sensor “empty”
  • Keywords “and” and “or”

Section 9 (Conditional Loop I)

  • Keyword “while”
  • Body of the loop, indentation
  • Use keyword “not” in while loops
  • Use conditions in while loops
  • Use additional commands before and after the while loop
  • Use multiple sequential while loops

Section 10 (Conditional Loop II)

  • Solve complex tasks that combine while loops, repeat loop and conditions
  • First maze algorithm (follow a path that only leads straight, turns left or turns right)
  • Solve simple tasks using the First maze algorithm

Unit 3

Section 11 (Custom Commands I)

  • Keyword “def”
  • Keyword “return”
  • Defining and using custom commands
  • Reuse existing custom commands to solve new tasks
  • Use multiple custom commands to solve a task

Section 12 (Custom Commands II)

  • Solve complex tasks by splitting them into simpler ones
  • Reuse existing custom commands to solve new tasks
  • Second maze algorithm (follow an arbitrary wall that is on your right)
  • Follow an arbitrary wall that is on your left
  • Solve simple tasks using the Second maze algorithm

Section 13 (Custom Commands III)

  • Solve complex problems that require the Second maze algorithm
  • Number of operations and program efficiency
  • Shorter program is not necessarily more efficient
  • Reuse existing custom commands to solve new tasks
  • Simplify a problem and solve it, then return to the original complex task

Section 14 (Variables)

  • Understand the role of variables
  • Various ways to initialize a new variable
  • Keywords “inc”, “dec”
  • Display values of variables using “print”
  • Use variables to count objects
  • Use variables to count other features in the maze

Section 15 (Functions)

  • Returning values
  • Measure the dimensions of objects
  • Understand the difference between global and local variables
  • Importance of using local variables

Unit 4

Section 16 (Comparison Symbols)

  • GPS device: keywords “gpsx”, “gpsy”
  • Using symbols ==, !=, <, > in conditions and while loops
  • Combining comparison symbols with keywords “and”, “or”

Section 17 (Boolean Values “True”, “False”)

  • Keywords “True” and “False”
  • Understand that sensors are functions that return either True or False
  • Use functions that return True or False
  • Combine True and False values with keywords “and”, “or”

Section 18 (Random Numbers)

  • Keyword “randint”
  • Model rolling one die
  • Model rolling two dice
  • Create random objects
  • Calculate minimum of a sequence of numbers
  • Calculate maximum of a sequence of numbers
  • Break complex tasks into simpler ones

 Section 19 (Lists I)

  • Create empty and non-empty lists
  • Append items to a list
  • Display lists
  • Use a list to store horizontal and vertical positions of objects in the maze
  • Store full GPS positions as [gpsx, gpsy] pairs
  • Keyword “for”
  • Use the “for” loop to parse lists
  • Check if an item is present in a list
  • Measure length of lists using the keyword “len”
  • Use a list to store the robot’s path in the maze

Section 20 (Lists II)

  • Keyword “pop”
  • Remove items from the end, beginning, and arbitrary position in a list
  • Use lists that contain Boolean values
  • Merge lists

Unit 5

Section 21 (Probability)

  • Keyword “rand” that returns randomly True or False
  • Use keyword “rand” to model coin toss
  • Understand that equal probability leads to a similar number of events
  • Understand that lower probability leads to a smaller number of events
  • Understand that higher probability leads to a larger number of events
  • Understand that the First and Second maze algorithm will not solve all mazes
  • Use coin toss for random walks in the maze
  • Solve mazes which cannot be solved using the First and Second Maze algorithms
  • Simulate the Binomial Distribution

Section 22 (Recursion I)

  • Understand what recursion is and when it should be used
  • Understand the importance of stopping condition
  • Always make the recursive call in a stopping condition
  • Typical mistakes in recursive algorithms
  • Solve problems using recursion
  • Use multiple recursive commands to solve a task

Section 23 (Recursion II)

  • Advanced applications of recursion
  • Combine recursive algorithms together
  • Use recursion to add a sequence of numbers
  • Use recursion to add lists
  • Use recursion to collect objects

 Section 24 (Advanced Applications)

  • Solve a task that requires three times nested loops
  • Collect objects in a complex maze, save their GPS positions
  • Find holes in a fence, and save their GPS coordinates
  • Recognize a number that is made from multiple maze objects
  • Save your path to a list, use the list to reproduce your path

Section 25 (World Class Challenges)

  • Measure the length of an arbitrary fence
  • Sort columns of pearls of random heights
  • Calculate the size of a fenced area without entering it
  • Check the correctness of a Cardan Grille
  • Check the correctness of a solution to the Eight Queens Problem
  • Traverse recursively a binary tree of apples