beanz Magazine

Random Dessert Generator

Kimberly Vardeman on Flickr

Unleash your inner digital chef through this simple (but mouth-watering) Python activity.

Who doesn’t love a good dessert? Whether it’s gooey fudge-brownie cake, piping hot peanut butter cookies, or rainbow popsicles with a thousand fruity flavours, I think we can all agree that sugary foods are awesome! To honour the sweet tooth, this activity is all about inventing new desserts. Using some simple Python code, we’re going to create a program that mashes flavours together into unexpected deliciousness.

Step 1: Setup

Navigate to www.replt.it and select ‘Python3’ from the ‘Search for a language’ bar:

Step 2: Create Lists

Now it’s time to put on your chef’s hat and get creative! Start by brainstorming three lists of words: one for flavours (chocolate, mint, watermelon), one for textures and bonus add-ons (sprinkles, cream, jelly), and one for desserts themselves (cake, brownies, parfait). Think up at least three words per category. When you’re done, code them up like so in the left-hand editor:

flavour = ["cherry", "chocolate", "vanilla", "caramel"]
bonus = ["swirl", "volcano", "mousse", "sprinkles"]
dessert = ["ice cream", "doughnut", "pie", "cookies"]

In this example, the words “flavour”, “bonus”, and “dessert” are all variables. A variable is the most basic building block in a program. Each one can be used to store a number, a word (also know as a “string”), or a list.

Become a subscriber and get access to the rest of this article. Plus all our magazine articles.

Stories also include numerous links to help parents, kids, and teachers learn more. Get access today at just $15 per year for online magazine only or $29.99/year for print + online ($35/year outside US)!

Subscribe Today!

Also In The August 2018 Issue

Use SketchUp to recreate the famous optical illusion that grows and shrinks people around the room.

Learn what makes a good rogue-like game and how to make one yourself.

Unleash your inner digital chef through this simple (but mouth-watering) Python activity.

Dinosaur fossils, STEM podcasts, and a day in the life of a paleontologist.

Real life treasure hunts are a way to get outdoors, learn map skills, and have fun finding hidden caches near you.

Tips & trips to help you have a great time on the Internet, even when others don’t behave well.

A fun introduction to programming games with fantasy computers. The 70s and 80s are back in style!

How scientists finally cracked the code behind the mysterious language of Ancient Egypt.

Two small projects introducing you to Edublocks, a language that bridges the gap between Scratch and Python.

Take your CLI skills to the next level as you combine, redirect, and script commands.

It looks like JavaScript, has a Python aesthetic, and integrates easily with C/C++. Meet Lua: a scripting language for fantasy computers.

How the high-tech LIGO made a huge discovery and won its three founders a Nobel Prize.

An introduction to the devices that’ll make your robots zoom, skitter, and spin.

Learn the secrets behind pixels, image blurs, and all your favourite Instagram filters!

Links from the bottom of all the August 2018 articles, collected in one place for you to print, share, or bookmark.

Interesting stories about computer science, software programming, and technology for August 2018.