Curbal has its own social media server on Mastodon. Check it out here!
Welcome to our Knowledge Base

Tip: Start typing in the input box for immediate search results.

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

Let us know your thoughts...

Table of Contents