Learning shapes, size and color

Learning shapes, size and color

Series: Python for kids

In our endavor to make learning fun and free of memorization, we have been using Python to allow children to experiment and analyze data to form their own opinion and discover facts. This way, children engage is learning process with more intensity and the they show higher retention rate vis a vis conventional learning.

This makes them think and try different things before they get it right. The focus shifts from being always 'right' to get it right after several failed attempts.

In this part of the series

Children create simple shapes using markers. They learn how to plot a shape, change color and size. They also learn show to find the shapes they can draw.

How to teach children

We give the some code to children to copy, paste and run. In this case, we send two lines of code:

import matplotlib.pyplot as plt
plt.plot( 0, 0, marker='o', color='red', markersize = 50)

The objective is not to teach coding but use it to learn basic concepts. In the above example, we teach children to change marker (shape), color and markersize (size).

The children experiment with shapes, colors and sizes. In future lessons, they learn about position of their shapes, thus leading to understanding of negative and positive numbers, co-ordinate systems, etc.

Import libraries

In [9]:
import matplotlib.pyplot as plt

Draw Circle

In [10]:
plt.plot( 0, 0, marker='o', color='pink', markersize = 50)
Out[10]:
[<matplotlib.lines.Line2D at 0x7fd753684810>]

Change color

Let them experiment with different colors. Ask them to put colors of their shirt or top, bottom, color of walls and other things that are present at that time. Thus, they will be able to develop sense of colors.

In [11]:
plt.plot( 0, 0, marker='o', color='green', markersize = 50)
Out[11]:
[<matplotlib.lines.Line2D at 0x7fd7535ee210>]
In [12]:
plt.plot( 0, 0, marker='o', color='grey', markersize = 50)
Out[12]:
[<matplotlib.lines.Line2D at 0x7fd75358a050>]
In [13]:
plt.plot( 0, 0, marker='o', color='brown', markersize = 50)
Out[13]:
[<matplotlib.lines.Line2D at 0x7fd7534e8a90>]

Change size

Let the children experiment. Ask them to try things like negative, zero or fractions too and compare them.

In [14]:
plt.plot( 0, 0, marker='o', color='green', markersize = 150)
Out[14]:
[<matplotlib.lines.Line2D at 0x7fd753523150>]
In [15]:
plt.plot( 0, 0, marker='o', color='green', markersize = 10)
Out[15]:
[<matplotlib.lines.Line2D at 0x7fd7537c5410>]
In [16]:
plt.plot( 0, 0, marker='o', color='green', markersize = 50)
Out[16]:
[<matplotlib.lines.Line2D at 0x7fd75367b150>]
In [17]:
plt.plot( 0, 0, marker='o', color='green', markersize = -50)
Out[17]:
[<matplotlib.lines.Line2D at 0x7fd7533b6550>]
In [18]:
plt.plot( 0, 0, marker='o', color='green', markersize = 15/4)
Out[18]:
[<matplotlib.lines.Line2D at 0x7fd75339bf90>]
In [19]:
plt.plot( 0, 0, marker='o', color='green', markersize = .50)
Out[19]:
[<matplotlib.lines.Line2D at 0x7fd7532fdf10>]

Square shape

In [20]:
plt.plot( 0, 0, marker='s', color='blue', markersize = 50)
Out[20]:
[<matplotlib.lines.Line2D at 0x7fd753268610>]
In [21]:
plt.plot( 0, 0, marker='s', color='red', markersize = 150)
Out[21]:
[<matplotlib.lines.Line2D at 0x7fd7532060d0>]
In [8]:
plt.plot( 0, 0, marker='s', color='black', markersize = 100)
Out[8]:
[<matplotlib.lines.Line2D at 0x7f82bd156ed0>]
In [ ]:
 

Draw triangle

In [22]:
plt.plot( 0, 0, marker='^', color='green', markersize = 50)
Out[22]:
[<matplotlib.lines.Line2D at 0x7fd753164b90>]

Draw Star

In [23]:
plt.plot( 0, 0, marker='*', color='grey', markersize = 50)
Out[23]:
[<matplotlib.lines.Line2D at 0x7fd75314f590>]

Draw Diamond

In [11]:
plt.plot( 0, 0, marker='d', color='orange', markersize = 50)
Out[11]:
[<matplotlib.lines.Line2D at 0x7f82bd009d90>]
In [ ]:
 

Draw Pentagon

In [12]:
plt.plot( 0, 0, marker='p', color='orange', markersize = 50)
Out[12]:
[<matplotlib.lines.Line2D at 0x7f82bcff39d0>]

Draw Hexagon

In [13]:
plt.plot( 0, 0, marker='h', color='pink', markersize = 50)
Out[13]:
[<matplotlib.lines.Line2D at 0x7f82bd3e41d0>]

Draw Octagon

In [24]:
plt.plot( 0, 0, marker='8', color='black', markersize = 50)
Out[24]:
[<matplotlib.lines.Line2D at 0x7fd75311f690>]

Draw Plus/Cross Sign

In [15]:
plt.plot( 0, 0, marker='P', color='yellow', markersize = 50)
Out[15]:
[<matplotlib.lines.Line2D at 0x7f82bce8aad0>]

Draw Heart Shape

In [16]:
plt.plot( 0, 0, marker=r'$\heartsuit$', color='red', markersize = 40)
Out[16]:
[<matplotlib.lines.Line2D at 0x7f82bce75750>]

Draw two shapes at a time

In [31]:
plt.plot( 0, 0, marker='o', color='red', markersize = 100)
plt.plot( 0, 0, marker='s', color='blue', markersize = 100)
Out[31]:
[<matplotlib.lines.Line2D at 0x7fd752e17650>]

Separate them

Teach them about position of shapes

In [30]:
plt.plot( 0, 0, marker='o', color='red', markersize = 100)
plt.plot( 0, 30, marker='s', color='blue', markersize = 100)
Out[30]:
[<matplotlib.lines.Line2D at 0x7fd752e25790>]
In [30]:
plt.plot( 0, 0, marker='o', color='red', markersize = 100)
plt.plot( 10, 30, marker='s', color='blue', markersize = 100)
Out[30]:
[<matplotlib.lines.Line2D at 0x7f82bc906f10>]

increase size of the figure

We send three lines of code to copy and paste as it is too early to teach them:

plt.figure(figsize=(10,10))

plt.xlim(-50, 50)
plt.ylim(-50, 50)

Now, we can experiment with left and right, up and down. It is good time to show them what negative and positive numbers do.

Pleace the square to right of the circle

In [33]:
plt.figure(figsize=(5,5))

plt.plot( 0, 0, marker='o', color='red', markersize = 10)
plt.plot( 20, 0, marker='s', color='blue', markersize = 10)

plt.xlim(-50, 50)
plt.ylim(-50, 50)
Out[33]:
(-50.0, 50.0)

Pleace the square to left of the circle

In [34]:
plt.figure(figsize=(5,5))

plt.plot( 0, 0, marker='o', color='red', markersize = 10)
plt.plot( -20, 0, marker='s', color='blue', markersize = 10)

plt.xlim(-50, 50)
plt.ylim(-50, 50)
Out[34]:
(-50.0, 50.0)

Pleace the square above the circle

In [35]:
plt.figure(figsize=(5,5))

plt.plot( 0, 0, marker='o', color='red', markersize = 10)
plt.plot( 0, 20, marker='s', color='blue', markersize = 10)

plt.xlim(-50, 50)
plt.ylim(-50, 50)
Out[35]:
(-50.0, 50.0)

Pleace the square below the circle

In [36]:
plt.figure(figsize=(5,5))

plt.plot( 0, 0, marker='o', color='red', markersize = 10)
plt.plot( 0, -20, marker='s', color='blue', markersize = 10)

plt.xlim(-50, 50)
plt.ylim(-50, 50)
Out[36]:
(-50.0, 50.0)

Now experiment with positions

In [37]:
plt.figure(figsize=(5,5))

plt.plot( -5, 20, marker='o', color='red', markersize = 10)
plt.plot( 20, -10, marker='s', color='blue', markersize = 10)

plt.xlim(-50, 50)
plt.ylim(-50, 50)
Out[37]:
(-50.0, 50.0)

All shape together

Assist the children in putting multiple shapes. Ask them to decide the postion of a news shape, left, right, up or down to a shape already drawn, before they draw it.

In [38]:
plt.figure(figsize=(20,10))

plt.plot( 10, 0, marker='o', color='red', markersize = 100)
plt.plot( 10, 30, marker='s', color='blue', markersize = 100)
plt.plot( 10, -30, marker='^', color='green', markersize = 100)

plt.plot( -10, 0, marker='*', color='grey', markersize = 100)
plt.plot( -10, 30, marker='d', color='orange', markersize = 100)
plt.plot( -10, -30, marker='p', color='purple', markersize = 100)

plt.plot( -30, 0, marker='h', color='pink', markersize = 100)
plt.plot( -30, 30, marker='8', color='black', markersize = 100)
plt.plot( -30, -30, marker='P', color='yellow', markersize = 100)

plt.plot( 30, 0, marker=r'$\heartsuit$', color='red', markersize = 100)
plt.plot( 30, 30, marker='>', color='lightgreen', markersize = 100)
plt.plot( 30, -30, marker='v', color='lightblue', markersize = 100)

plt.xlim(-50, 50)
plt.ylim(-50, 50)
Out[38]:
(-50.0, 50.0)
In [ ]:
 

List of markers

In [ ]:
 
In [ ]:
 

Machine Learning

  1. Deal Banking Marketing Campaign Dataset With Machine Learning

TensorFlow

  1. Difference Between Scalar, Vector, Matrix and Tensor
  2. TensorFlow Deep Learning Model With IRIS Dataset
  3. Sequence to Sequence Learning With Neural Networks To Perform Number Addition
  4. Image Classification Model MobileNet V2 from TensorFlow Hub
  5. Step by Step Intent Recognition With BERT
  6. Sentiment Analysis for Hotel Reviews With NLTK and Keras
  7. Simple Sequence Prediction With LSTM
  8. Image Classification With ResNet50 Model
  9. Predict Amazon Inc Stock Price with Machine Learning
  10. Predict Diabetes With Machine Learning Algorithms
  11. TensorFlow Build Custom Convolutional Neural Network With MNIST Dataset
  12. Deal Banking Marketing Campaign Dataset With Machine Learning

PySpark

  1. How to Parallelize and Distribute Collection in PySpark
  2. Role of StringIndexer and Pipelines in PySpark ML Feature - Part 1
  3. Role of OneHotEncoder and Pipelines in PySpark ML Feature - Part 2
  4. Feature Transformer VectorAssembler in PySpark ML Feature - Part 3
  5. Logistic Regression in PySpark (ML Feature) with Breast Cancer Data Set

PyTorch

  1. Build the Neural Network with PyTorch
  2. Image Classification with PyTorch
  3. Twitter Sentiment Classification In PyTorch
  4. Training an Image Classifier in Pytorch

Natural Language Processing

  1. Spelling Correction Of The Text Data In Natural Language Processing
  2. Handling Text For Machine Learning
  3. Extracting Text From PDF File in Python Using PyPDF2
  4. How to Collect Data Using Twitter API V2 For Natural Language Processing
  5. Converting Text to Features in Natural Language Processing
  6. Extract A Noun Phrase For A Sentence In Natural Language Processing