5 Basic Python Concepts Kids Should Know

By 5 Basic Python Concepts Kids Should Know

Python is one of our favorite coding languages and nowadays it’s more popular than ever.

Python powers websites like YouTube and Instagram. So you might be surprised to hear that Python is easy to learn and a good choice for kids. It was written to be more readable and intuitive than similar back end languages. 

There 5 are core concepts we recommend your child learn to build a solid foundation in Python: data types, variables, functions, loops, and modules.

1. Data Types

A data type is a classification of data that tells the compiler how to use a piece of data. It determines what values an object can have and the operations that can be performed on it. Most programming languages support basic data types such as numbers, characters, and booleans.

In Python there are standard data types kids should be familiar with:

  • Integer: 20
  • Float: 20.5
  • String: “CodeWizardsHQ”
  • List: ["apple", "banana", "cherry"]
  • Tuple: ("apple", "banana", "cherry")
  • Dictionary: {"name" : "John", "age" : 36}

To see the data type of an object, use the type() method in Python.

input:

str='ericmuchenah blog'
print(type(str))

output:

<class 'str'>

2. Variables

Variables are containers that hold a value, such as a piece of text or a number. You might remember these from math class. Variables are powerful because they can be reused and changed easily.

You can assign a value to a variable, like x or y, using the equal sign:

input:

x = 5 
y = 'John'

Variable names cannot: 

  • start with a number
  • contain spaces.
  • contain special characters except “_” (underscore)
  • have same name as another variable

3. Functions

A function is a block of code which performs an action when it is called. You can add arguments to pass data into a function. A function can return data as a result.

input:

def coolfunction();
print('My cool function prints this phrase)
coolfunction()

output:

My cool function prints this phrase

4. Loops

A loop is a block of code that runs over and over. In Python there are two types of loops: for loops and while loops.

A for loop repeats a series of commands over a sequence of data, like a list.

input:

fruits = ["apple", "banana", "orange" ]
for x in fruits:
print(x)

output:

apple

banana

orange

A while loop repeats a series of commands as long as certain conditions are true. 

input:

i = 1
while i < 5
print(i)
i += 1

output:

1

2

3

4

5

5. Modules

Python modules are files that contain a set of code which you can include in your application. You can use Python’s in-built modules or write your own.

For example, you can import the math module in order to use the sqrt() function that exists there, instead of writing your own function to calculate the square root.

input:

import math
x = math.sprt(81)
print(x)

output:

9

Having a solid foundation in these core concepts will give your child the skills and confidence to keep learning. 

Read more about Python for kids including tips, tutorials, and books on the blog. For the most fun and effective Python classes, check out this middle school and high school coding program.

However you do it, encourage your child to keep coding.

Was this article helpful?
Donate with PayPal: https://www.paypal.com/donate

Bessy
Eric Murithi Muchenah

Life is beautiful, time is precious. Make the most out of it.