If you’ve never heard of a function, this lesson may be hard to understand but the function is one of the most fundamental building blocks of any programming language. This tutorial will teach you about some of the key ideas of functions in python. A basic function A function has syntax similar to the if […]
Month: April 2020
Lists
In this lesson, we will learn about lists (also called arrays) in python. A list is a datatype. A list can contain multiple elements. Each element can be any data type including a list. The elements are separated by commas in between square brackets: items = [“bread”, “chicken”, “eggs”]price = [2, 5.34, 0.45] Try printing […]
The While Loop
We have already learned about the for loop and now it is time to learn about the while loop. The while loop is like a combination of the for loop and the if function. The while loop looks like the following: while(Boolean):—-Do Something The While Loop will run as long as the Boolean in it’s […]
A Challenge
Use the skills you’ve learned throughout the past lessons to make a game. If it’s too hard, don’t worry, you can skip this and come back anytime. LeaderBoards 1st Place: None 2nd Place: None 3rd Place: None Challenge Description In this game, create a variable called health. Make it so each “turn” a random outcome […]
If function
When we were first developing our game, I introduced this If function. In this lesson, I will talk to you about how it works. Boolean Datatype To understand the If function properly, we first need to understand the Boolean data type. A Boolean can be either True or False. We can store their value in […]
For Loops
So far in our guess the number game, the user only gets one guess. In this tutorial, we will show you how to allow the player to get more guesses using for loops In a for loop, a given command is repeated the desired amount of times. The code for this is: For i in […]
Your First Game
After all these past lessons, you’re finally ready to make your first game! In this game, a computer will generate a number from 1 to 100 and you will have to guess it. In this first tutorial, we will make the game and in the next, we will improve it. Random module To make this […]
Taking Input in Python
If you’ve been following my tutorials, you may be thinking: “Luke, this is all interesting, but what is the use of all of this if our code is not interactive?” After all, a movie is interesting but a video game is usually more engaging. I’m going to get straight to the point this time. The […]
Variables in Python
This is the last boring lesson before we start something fun. In this lesson, we are going to learn about variables in python. As you may know, a variable is like a box, it stores a value. For example, if is x is our variable than x is the name of the box. We can […]
Math in Python
You don’t need to be a math genius to learn to code, however some basic knowledge is needed. Today we will learn how to do basic mathematical operations in Python. Last article, we learnt about the string data type (wrapped in quotation marks). Today we will learn about the int data type. An int is […]