@extends('template')
@section('title')
Lab 2 Functions 1
@stop
@section('content')
# Lab 2 Functions 1
## Goals
Hello
- Use basic Python functions and operators
- Run code step-by-step in Thonny
- Define custom functions that use `print`
- Define custom functions which are fruitful
- Use functions with `turtle` graphics or `wavesynth` audio (your choice)
@include('/labs/lab02/_toc')
## Big Questions {.bigqs}
- *What's the difference between `print` and `return`?*
Show Answer
There are a few differences:
1. The `return` value from a function can be used by other functions
or code, or stored in a variable. Text printed using `print`
cannot be stored in a variable or used by other code.
2. A function can use `print` however much it likes, but it can only
have one return value.
3. When you run a single line of code in the shell, both anything
that it prints using `print` *and* its result value are
displayed. But when you run code in your file, only output
created using `print` will show up.
- *What is the first step when writing a custom function?*
Show Answer
Before anything else, you should write your documentation string!
This allows you to create a plan for what the function will do, as
you describe it. Often, you will find that you either don't
understand enough details to describe it, or you realize something
about what your code needs to do as you describe it, both of which
can save you a lot of time.
@endsection