Python for Kids

Blogs, articles, free Python projects and more for kids and teens learning to code with Python.


How to increment a value in a Python dictionary

Jan 31 2022

Learn three different ways to increment a value in a Python dictionary!
Read more
How to obtain the first key in a Python dictionary

Jan 31 2022

Become a Python dictionary expert by learning how to find the first key in a given dictionary!
Read more
How to convert a string to a float in Python

Jan 23 2022

Learn how to convert a string to a float in Python using just one function call!
Read more
Find all permutations of a given string in Python

Jan 23 2022

How do you find all permutations of characters in a given string? This is one of those examples where recursion proves to be an ideal way to approach the problem.
Read more
Flattening a nested list in Python

Jan 19 2022

Learn how to flatten a nested list in Python!
Read more
When would you need a nested lambda in Python?

Jan 19 2022

A lambda is an unnamed, anonymous function in Python. A nested lambda is a lambda within a lambda. Learn when you might need it!
Read more
How to convert a Python list to a numpy array

Jan 17 2022

Learn the intricacies involved in converting a regular python list to a numpy array and what your options are!
Read more
How to check if two numpy arrays are equal

Jan 17 2022

Sometimes you will want to make an element-wise comparison of two numpy arrays. There is a function for that!
Read more
Python numpy.histogramdd()

Jan 14 2022

Python’s numpy.histogramdd() is a very useful function to compute histograms out of multidimensional data. Learn the different ways to use it!
Read more
Python's numpy.ones() function

Jan 14 2022

Python numpy has a handy function to create an array of specified shape and type, filled with ones. Check it out!
Read more
How to compute the Manhattan distance in Python numpy

Jan 9 2022

Want to find the distance by foot between two locations in Python? Learn how to compute the Manhattan distance!
Read more
How to compute the Euclidean distance in Python numpy

Jan 9 2022

Want to find the shortest distance between two cities in Python? The numpy module has many options for you!
Read more
Does Python allow multiline lambda functions?

Jan 8 2022

Lambda functions are 'use and throw' functions. Learn if you can split a lambda function across multiple lines and what the rules for writing lambda functions are!
Read more
Python max() using lambda functions

Jan 8 2022

Sometimes you just want to create your own custom maximum function; Python lambdas have a solution for you!
Read more
How to convert a Python range to a list

Jan 7 2022

In your Python journey you will encounter a need to convert a Python range into a list. Learn three ways to do so!
Read more
How to reverse a range in Python

Jan 7 2022

Ranges are a staple of iteration in Python. Learn how to reverse a range!
Read more
How to convert a comma-separated string into a list in Python

Jan 5 2022

Learn how to convert a comma-separated string into a list in Python, a very common operation!
Read more
Python program for finding the greatest common divisor

Jan 5 2022

Learn how to distribute candy evenly by computing the greatest common divisor!
Read more
How to check if a Python String is CamelCase

Dec 29 2022

A CamelCase string is one like Kodeclik or KodeclikOnlineAcademy, but not kodeclikonlineacademy. How can you check if a Python string is in CamelCase format?
Read more
How to apply a function to all elements of a Python list

Dec 20 2022

Applying a function to each element of a list is such a handy and useful capability that you should learn all the ways Python makes it easy to do so!
Read more
How to check for an empty string in Python

Dec 20 2022

In your Python journey, you will come across scenarios where you will need to check if a Python string is empty. Learn three ways to accomplish this frequent task.
Read more
How to convert strings to bytes in Python

Dec 2 2022

Ever wondered how Python internally represents a string as bytes? There are handy functions to explore that!
Read more
Python’s os.path.join() function

Nov 29 2022

The os.path.join() function in Python is a clean way to concatenate different strings to construct a complete filepath. Learn why and how to use it!
Read more
How to import a class from another file in Python

Nov 29 2022

Python modules help logically organize code into multiple files; learn how to import a class from another file!
Read more
Python os.chdir()

Nov 27 2022

Learn how to programmatically move between directories in Python!
Read more
Python os.remove()

Nov 27 2022

Learn how to programmatically delete a file from within Python!
Read more
Python os.listdir()

Nov 23 2022

Ever wanted to explore your directory but from within Python? Learn how!
Read more
How (and why) to nest classes in Python

Nov 22 2022

Nested classes are those that are defined inside other classes. Learn when you will need this feature and how they are useful in object oriented programming!
Read more
How to skip values in a Python list

Nov 22 2022

In processing lists in Python you might find a need to skip values in the list. Learn four different ways to do so!
Read more
How to sort a list of tuples in Python

Nov 18 2022

What if you have a list of tuples and desire to sort it in your own way? Learn two popular methods to do so!
Read more
Python Nested Lists

Nov 18 2022

Nested lists are useful data structures that are basically lists comprised of other lists. Learn when and how to use them in Python!
Read more
How to unzip a list of tuples in Python

Nov 14 2022

Learn how to unzip a list of tuples in Python, from the easiest to the most Pythonic way!
Read more
List subtraction in Python

Nov 14 2022

Learn six different ways to do element-by-element subtraction of two lists in Python!
Read more
Python os.mkdir()

Nov 13 2022

Ever wanted to create directories programmatically from within Python? It is so easy!
Read more
Python vars()

Nov 13 2022

The vars() function in Python inspects an object and returns a dictionary identifying the changeable attributes of the object along with their current values.
Read more
The next function in Python

Nov 12 2022

The next() function in Python retrieves the next item from an iterator (constructed over a data structure such as a list or dictionary). Learn how to use it!
Read more
How to swap positions of values in a Python dictionary

Nov 12 2022

Looking for a Python-ic way to swap positions of values in a Python dictionary? It just takes a few lines of code!
Read more
Is Python case sensitive?

Nov 11 2022

As your journey into Python goes forward you will come to a point where you wonder if Python is case sensitive. Read on!
Read more
How to create an inclusive range in Python

Nov 11 2022

The Python range function behaves in an off-by-one manner in how it does not include the end value. Learn how to create an inclusive range function!
Read more
How to reverse a range in Python

Nov 8 2022

Sometimes you will need a loop in Python that counts down rather than counts up. Learn how to reverse a range in Python!
Read more
Python's divmod() function

Nov 8 2022

Python’s divmod() is a very handy function that returns both the quotient and remainder of a division in a single step!
Read more
Math.tan() in Python

Nov 7 2022

Learn to compute the tangent trigonometric ratio in Python with the Math.tan() function.
Read more
Math.cos() in Python

Nov 7 2022

Learn to compute the cosine trigonometric ratio in Python with the Math.cos() function.
Read more
Math.sin() in Python

Oct 17 2022

Learn to compute the sine trigonometric ratio in Python with the Math.sin() function.
Read more
Math Domain Error in Python

Oct 17 2022

Learn to solve 'math domain errors' in Python, one of the most common but sometimes frustrating error messages!
Read more
Python’s math.isclose() function

Oct 8 2022

Learn about the math.isclose() function in Python and how to use it!
Read more
Python program to print all prime factors of a given number

Oct 8 2022

Learn how to factorize a number into its prime factors in Python, in two different ways!
Read more
math.floor() in Python

Oct 6 2022

Learn about the math.floor() function and when to use it!
Read more
math.ceil() in Python

Oct 6 2022

Learn about the math.ceil() function and when to use it!
Read more
Computing the nth row of Pascal’s Triangle

Oct 4 2022

Pascal’s triangle is a very useful construct in discrete math and can be easily computed in Python. Learn how!
Read more
What does [-1] mean in Python?

Oct 4 2022

Did you know you can retrieve the '-1'th element of a Python list? What? What does that mean?
Read more
Histograms in Python

Jul 3 2022

A histogram is a plot of the counts of (grouped) items in a given dataset. Learn how to compute histograms in Python!
Read more
How to iterate through a Python dictionary

Jul 3 2022

Have a Python dictionary and would like to loop through it? Here are four ways to do so!
Read more
How to merge multiple files into a single file in Python

May 21 2022

Given two or more files how do you merge them into a single file? Learn to write a Python program to do just that!
Read more
How to implement a Stack in Python

May 21 2022

A stack is a last-in-first-out (LIFO) data structure. Learn the many ways to create a stack in Python.
Read more
How to initialize a Queue in Python

May 21 2022

A queue is a first-in-first-out (FIFO) data structure. Learn the many ways to create a queue in Python.
Read more
How to count in a Python loop

May 19 2022

Python loops are so expressive that you can do two things at once: count and iterate!
Read more
How to remove parentheses from strings in Python

May 19 2022

Have a Python string and need to remove parentheses from it? Learn three ways to do so!
Read more
How to iterate through multiple lists in Python

May 19 2022

Have two or more lists and need to iterate through them simultaneously? Here are the ways.
Read more
How to check if two dictionaries are equal in Python

May 18 2022

Looking for a quick way to compare two dictionaries in Python? Learn how!
Read more
How to take input until Enter is pressed in Python

May 18 2022

Can you write an interactive Python program to take inputs from the user till the Enter key is pressed? Learn how!
Read more
Python’s range() function

May 10 2022

Python’s range() function is very handy to write loops because it returns a list of numbers within a specified span of values.
Read more
Python’s sum() function

May 10 2022

Python’s sum function takes an iterable and returns the sum of elements in it. Learn how to use it!
Read more
Splitting a Text File by Lines in Python

May 9 2022

Learn about four different ways to split a text file in Python into lines. Which one is your favorite?
Read more
How to convert a set to a tuple in Python

May 9 2022

Have a Python set and want to convert it into a tuple? Learn three ways to do so!
Read more
How to remove trailing zeros in Python

May 4 2022

Have a Python string denoting a decimal and need to remove trailing zeros? Learn how!
Read more
How to remove leading zeros in Python

May 4 2022

Have a Python string denoting a number and need to remove leading zeros? Learn how!
Read more
Stacks in Python

Apr 3 2022

Stacks are one of the most useful data structures in Python. Learn how to use them!
Read more
Python’s file naming convention

Apr 3 2022

How should you name your Python files, functions, classes, modules, and packages? Read on to learn how!
Read more
Method Overloading in Python

Feb 20 2022

Can you have a Python program where a method has different meanings at different points in a program? Yes!
Read more
Tuple Index Out of Range!

Feb 20 2022

Do you get the dreaded “Tuple Index Out of Range” error in your Python program? Learn what it means and how to fix it!
Read more
Measuring Elapsed Time in Python

Feb 20 2022

Would you like to time your Python program to see how fast it runs? Learn about ways to measure elapsed time!
Read more
Ordered Sets in Python

Feb 20 2022

An ordered set is just like a set in that it disallows duplicates but it maintains the order of elements. Learn how to implement ordered sets in Python!
Read more
Python Set pop()

Feb 18 2022

Have a Python set and want to pop an element? Here’s how to do it!
Read more
How do you measure file size in Python?

Feb 18 2022

You will sometimes encounter the need to measure the size of files from within a Python program. Here are 5 ways to do so!
Read more
Python toString()

Feb 18 2022

Learn how to print any object into a string using Python’s custom methods!
Read more
Python's str() function

Feb 17 2022

It is sometimes handy to take an object and convert it into a string. Learn Python’s very useful str() function!
Read more
Can your Python string be an integer?

Feb 17 2022

Have a string and need to check if it actually denotes an integer? Here are 4 ways to do so!
Read more
Prepending to a list in Python

Feb 15 2022

If you dabble in Python lists, here are useful ways to prepend elements to a list!
Read more
Python’s Double Slash

Feb 15 2022

Do you know the difference between 5/2 and 5//2 in Python? When do you use which operator?
Read more
Boolean Operators in Python

Feb 13 2022

Learn how to write boolean expressions using Python’s in built boolean operators!
Read more
Private Methods in Python

Feb 13 2022

Private methods in a Python class are a good way to encapsulate functionality. Learn when you can make use of them!
Read more
Formatting strings in Python

Feb 9 2022

Python has versatile ways to format strings, i.e., to create strings from templates. Learn how they work!
Read more
How to send emails using Python

Feb 9 2022

Need to send hundreds of emails and looking for a convenient solution? Learn how to use a mail API and Python to programmatically send emails!
Read more
The Python __call__ method

Feb 8 2022

Learn about Python’s special method __call__ which makes objects callable, leading to more readable code!
Read more
Print a Python List (5 ways)

Feb 8 2022

Python is one of the most multifaceted languages out there; learn about 5 different ways to print a list! Which one is your favorite?
Read more
Python hasattr()

Feb 7 2022

hasattr() is a very useful function in Python that can be used to check if a given object has a specified attribute.
Read more
Python's not in operator

Feb 7 2022

'not in' as the name indicates is an operator that checks if a given input is not present in a given sequence. See where we can make use of it!
Read more
Python pow()

Jan 31 2022

What is the remainder when 7 to the power of 49 is divided by 5? Python’s pow() is a handy function to get you the result in one line!
Read more
Python chr()

Jan 31 2022

Ever wonder how Python stores characters internally? Learn about the Python chr() function!
Read more
Python’s min function

Jan 30 2022

Analogous to max(), the min() function in Python takes an iterable (e.g., a list) as input and returns the minimum value in that iterable.
Read more
Python’s max function

Jan 30 2022

The max() function in Python is a versatile function that takes any type of iterable (e.g., a list) as input and returns the maximum value in that iterable.
Read more
Initializing a Python dictionary

Dec 30 2021

Learn about 8 different ways to initialize a Python dictionary. Which one is your favorite?
Read more
Empty Dictionaries in Python

Dec 30 2021

Learn how to work with empty dictionaries in Python: creating them and testing for emptiness.
Read more
Python Dictionary Length

Dec 30 2021

Dictionaries hold key-value pairs in a data structure and it is often useful to find the length of a dictionary. Learn how!
Read more
Python’s Inline If

Dec 30 2021

If...else statements are important to any Python programmer; the inline if is a shorthand that leads to more readable statements.
Read more
Python Memory Errors: Why they happen and how to fix them

Dec 30 2021

Memory errors can occasionally happen in your Python program. Learn four reasons why they happen and how to to fix them.
Read more
Printing to stderr in Python

Dec 30 2021

stderr, or 'standard error', is the channel where error messages from your Python program are recorded. Learn how to print to stderr from your program.
Read more
How to capitalize the first letters of words in a string

Dec 30 2021

Haven’t you found it necessary to sometimes take a string and capitalize the first letter of each word? Here are 5 handy ways to do so.
Read more
Python’s XOR Operator

Dec 30 2021

The XOR operator in Python computes the logical exclusive disjunction of two boolean variables or two binary numbers.
Read more
Python’s If Not Operator

Dec 28 2021

Python’s if not operator tests if some condition is not true and can be a succinct way to describe some types of program logic.
Read more
How to Copy a List in Python

Dec 28 2021

Learn about the many ways to copy a list in Python and which one to use in a given setting.
Read more
Python startswith(): A Simple Guide

Dec 28 2021

Python startswith() is a very handy method to check if a string starts with a certain prefix.
Read more
Python’s isnumeric() method

Dec 28 2021

Python strings sometimes are made up of numbers and can thus be interpreted in a numerical manner. isnumeric() is a very useful method for Python programmers.
Read more
Finding the length of a Python list

Dec 27 2021

How do you find the length of a list in Python? Learn about Python’s built-in len() method and other functions.
Read more
Python's Ternary Operator

Dec 27 2021

Ternary operators in Python are nice syntactic shorthands for conditional statements that make your program more readable. Read on to understand how and when to use them.
Read more
All about Python Empty Lists

Dec 27 2021

Checkout this handy tutorial to create empty lists in Python or check if a given list is empty.
Read more
Writing to a File in Python

Dec 27 2021

Python has very useful functions that make it easy to write to text files and even append to existing files. See how!
Read more
How to Open a Text File in Python

Dec 14 2021

It is easy to use Python to read content from a file and process them in your program. Read on to see how!
Read more
How to Concatenate Strings

Oct 26 2021

Concatenating strings refers to joining them one after the other. Python provides multiple ways to concatenate strings.
Read more
Python Pointers: Do we need them?

Oct 25 2021

Pointers are very common in low-level languages like C and C++ and although you do not need to use them explicitly in Python, understanding how they work behind the scenes will make you appreciate many implementation details.
Read more
Python reduce()

Oct 19 2021

Python’s reduce() function takes a function and uses it to perform a rolling computation over an iterable such as a list.
Read more
Python map()

Oct 19 2021

Python’s map() function can be viewed as a shorthand for a for loop. It takes a function and an iterable (e.g., a list or array) and applies the same function on each element of the iterable.
Read more
Python Set Operations

Oct 17 2021

Discover Python sets! Python provides a very flexible set data structure and a wide range of operations so you don’t have to implement your own.
Read more
The Fibonacci Sequence

Sep 27 2021

Fibonacci numbers are a famous sequence of numbers that occur in many natural contexts. Learn how to generate and experiment with them using Python programs.
Read more
What is a loop in programming?

Sep 27 2021

A loop is a basic building block of coding and is referred to as a programming structure. Let’s take a look at the types of loops and how they are used within a program.
Read more
The Beginner's Guide to Python Turtle

Sep 13 2021

Python’s Turtle is a popular module that provides many useful functions for drawing graphics, animations, and games. Learn how you can command the turtle to draw graphics!
Read more
What is Python used for?

Aug 2 2021

Learn why Python is one of the most popular programming languages out there and the myriad places where it is used.
Read more
The Python sqrt() function

July 19 2021

Python’s sqrt() computes square roots and you can use it in interesting ways to solve mathematical problems.
Read more
The Python print() function

July 18 2021

Python’s print() is a versatile function that provides various options to format and style the output from your programs.
Read more
Recursion in Python

July 17 2021

Recursion is a style of programming where a function calls itself one or more times repeatedly until a desired condition is met. Many classical algorithms in computer science are recursive in nature.
Read more
Magic Square Generator

July 15 2021

Magic squares add up to the same number along rows, columns, and diagonals. Here is a Python program to generate them.
Read more
Pygame Tutorial

July 14 2021

Learn to use the Pygame library in Python to create your first game. This tutorial is meant for beginners looking to get started with Pygame.
Read more
Everything you wanted to know about pygame

July 13 2021

Learn about the Python pygame library and its capabilities.
Read more
Arrays versus Lists in Python: What is the Difference?

July 10 2021

Arrays and Lists are two very similar data structures in Python but have important differences. Read on to learn about them!
Read more
Solving the Tower of Hanoi in Python

July 9 2021

Learn about this ancient mathematical puzzle and the classical computer science solution to it, along with a Python implementation.
Read more
How to make a password generator in Python

July 8 2021

Learn to write your own Python program that will generate a random password.
Read more
5 Algorithms and their popular applications

July 6 2021

Algorithms are pervasive in computer science - read this post to learn about five of the most popular algorithms and their myriad applications.
Read more
Quicksort Primer

July 5 2021

Quicksort is a very popular in-place sorting algorithm so named because it is significantly faster than many other sorting algorithms. Learn about it including an implementation in Python.
Read more
Merge Sort Primer

July 3 2021

Merge sort is a classical divide-and-conquer algorithm. Learn the details of how merge sort works and a sample implementation in Python.
Read more
Insertion Sort Primer

July 2 2021

Insertion sort is a very simple algorithm for sorting, mimicking the way you sort cards in your hand. Get into the details of how Insertion Sort works and a sample implementation in Python.
Read more
Bubble Sort Primer

June 29 2021

Bubble Sort is a very popular and simple algorithm for sorting. Learn how Bubble Sort works and how to implement it using Python.
Read more
Learn Python enumerate()

June 28 2021

Python’s enumerate() function is used to loop through strings, list, arrays and any other iterable object. Use iterators to build a search engine!
Read more
What are algorithms?

June 25 2021

What is an algorithm? How do they surface in our everyday lives? Learn about the history of algorithms, the types of algorithms, and some famous algorithms in computer science.
Read more
How to make a Random Number Generator in Python

June 23 2021

Random numbers are crucial to realism in gaming, cryptography, and simulation. Learn all about random numbers, how they are used, and how to generate them in Python.
Read more
Top 6 Python libraries for kids

Dec 10 2019

Learn about several fun-tastic Python libraries for kids to get into turtle graphics, game playing, machine learning, and more!
Read more
  • ABOUT

Copyright @ Kodeclik 2022. All rights reserved.