← Back to the Introduction to Computer Science outline The Course Maker
← Introduction to Computer Science outline
Week 7 · Module overview

Week 7 — Functions

Introduction to Computer Science Free sample edition

Welcome to your Week 7 Start Here page.

Why this matters

A nursing student whose dosage calculator runs one conversion for every chart and a business major whose spreadsheet applies one tax rule to every line of a receipt both rely on work written once and reused with new values.

In plain language

So far every program you wrote ran from top to bottom, one line after another, and if you needed the same work twice you typed it twice. This week you learn to give a piece of work a name and run it whenever you want. A function (a named block of code that runs when you call it) is written once and reused as often as you like. You will hand a function values to work on, get a value back from it, and learn where the names inside a function live and when they disappear. As always, you predict what each program prints and then run it to check.

  • Already covered: loops, counters, and accumulators from Weeks 5 and 6.
  • This week: def, parameters and arguments, return and None, scope, and three bugs.
  • How they connect: a function packages your loops and expressions under one name.
  • Where we're going next: Week 8, Midterm Review & Exam.

Focus

How do you package a piece of work once, hand it values, and use what it hands back?

By the end of this module, you should be able to:

  • [ ] predict what a function call hands back
  • [ ] tell return from print and spot the None
  • [ ] fix a missing return, a print, and a stray local

To-do

Plan your week

  1. Read Chapter 7 (about 45 minutes), then the lecture and slides.
  2. Work the lecture tutorial (60–90 minutes) and the practice set (about 20 minutes).
  3. Do the Coding Lab (about 90 minutes), the discussion, and the assignment.
  4. Take the quiz.

This week's checkpoint: predict what print(show(4)) prints, run it, and explain the second line.

You've got this

Predict, then run, and ask your instructor if a step snags.

Built with The Course Maker · samples.thecoursemaker.com