Print

Bite 2: Functions, global and local variables

In this Bite we are going to learn:

1. How to create functions
2. Understand global and local variables
3. Create the first bit of our game

Theory

Jupyter Lab notebook available here.

Bite 2: Functions, global and local variables | Python mystery game

Practice

With what you just learned, can you create the program below using functions?

You will create two functions: “intro” will contain the introductory text and “username” will contain the part where we ask the user for their name.

You will then greet the user by their name outside both funcions.

The solution

Bite Solution 2: Functions, global and local variables | Python mystery game
Was this helpful?

Reader Interactions

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents