CS-121

Introduction to Programming

A Deckset-style Play fixture

What is programming?

Programming is the process of writing instructions for computers to follow.

What can you do with code?

  • Solve problems for people
  • Express an idea precisely
  • Automate repetitive work
  • Build tools that change what is possible

Variables

name = value

name = "Ada"
age = 36
language = "Python"

Functions

def greet(name):
    return f"Hello, {name}!"
  • Give a useful operation a name
  • Accept inputs
  • Return an output

Quick practice

Write an is_even(number) function that returns True for even numbers.

When you are ready, show the solution.

Solution

def is_even(number):
    return number % 2 == 0

Go time

  • Focus on code
  • Ask for help
  • Test and iterate