Python -The First Language For Kids

Computer Terminology

Before we start to discuss Python, let us review some of the terms (words) you will see in the rest of this book. Since you have been using the computer at home for playing games and doing homework, etc. you are perhaps familiar with these terms.  Skip this section if you already know the below terms.

Computer

A computer is a machine that is used to solve a problem. The problem may relate to Math, Physics, Chemistry, Medicine, Biology, or Engineering.  The computer stores your data, does computations on the data, following the instructions in your program, and outputs the results of the computation on your computer screen. By itself, the computer cannot do anything; it needs a detailed set of instructions on what to do. The detailed set of instructions is called a program.

Program or Programming 

A program is a detailed set of step-by-step instructions that you, as a programmer, would like the computer to follow; it tells the computer what to do and in what order. Writing the detailed set of instructions in the program is called programming (or coding). This code that is run on the computer is called a program.

Language

The computer does not understand English, so we cannot talk to the computer in English.  We need to talk to the computer in a language it can understand. There are many languages the computer can understand.  Python is one of the languages.  Programs can be written in Python (or any other programming language).

Data

Data is the input you provide to the program through keyboard or from a file.

Input

Input is something that you type from the keyboard. The input let you give data to Python and interact with Python.  Python treats all inputs from the keyboard as strings. (You will learn about strings in a later section.)

Output

The computer does the computations as per instructions in your program and the data you provide.  The results of the computations are called output. Normally, you see the output on the computer screen or are sent to a file.

Memory

The computer has many components. The two we are going to mention here are the Central Processing Unit (CPU) chip and the Memory chip. The CPU does the computations on the data that you input into the program.  The memory chip stores the data that you input to the computer. The memory chip can store billions of bits of data. 

Just as your house has an address that the mailman uses to deliver your mail, each location of the bit of data (called byte in computer lingo) in the memory chip has an address. The CPU uses this address to access (read) the data from the memory, do computations on it, and store the results back to the memory chip at an address specified in your program.

Pixels

If you look at your computer screen very closely (using a magnifying lens), you would see very tiny dots (points).  Typically, the number of dots is 1280 horizontally and 1024 vertically.  Some of the high-resolution computer screens may have more dots: 1920 in horizontally (x-direction) and 1080 vertically (y-direction).

On a white screen, each of the dots becomes colored or black when the program data needs to make the dot show color, else the dot will stay white. Each of the dots (squares) is called a pixel. A pixel is a physical point in the computer screen and is a tiny square as shown in the picture on this page and next.  In the image, each little square is a pixel.

Credits: Image from the site below.

<a href=”https://www.bbc.co.uk/bitesize/topics/zf2f9j6/articles/z2tgr82“>

Python Start-up Screen

After you have installed Python on your computer and created a shortcut (IDLE or pythonw) on your desktop, you are ready to learn how to write small Python programs.

To start the Python interpreter, double-click the IDLE icon on the desktop. The image shown below will appear on your desktop. It is called a Python Shell Window. Notice the triple right arrows (>>>). The >>> is called the prompt.  This is where you write the commands to the computer. We will come back to this after we introduce a few Python instructions. 

Commenting Your Code

It is always a good idea to write comments in your code.  It helps the reader to understand your thinking and intentions. There are many ways to insert comments in you code.  The following example illustrates various ways to insert comments.

A hash sign (#) that is not inside a string literal begins a comment. All characters after the # and up to the end of the physical line are part of the comment and the Python interpreter ignores them. It is meant only for the reader.

You can type a comment on the same line after a statement or expression by typing # character or you can start your comment on a new line beginning with # sign.

If you would like a comment that spans several lines, you can use triple single quotes (‘’’) as in the below example.

Program Example: How to Add Comments to Program
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> # This is a program to show how comments are inserted in the code.
>>> name = 'Michael' # This is an example of writing comment on the same line after the statement
>>> # Below is an example of multi-line comment.
>>> '''
This comment will
span several
lines.
'''
>>>

Copyright © 2019 – 2024 softwareprogramming4kids.com

All Rights Reserved

Verified by MonsterInsights