This lessons of Python programming are being prepared especially for middle-school students:
(Time: 40 minutes)
• First of all, we need a Computer/Laptop with at least 4GB RAM. (8GB RAM will be better, of course)
• Python is free and open-source.
• Python comes pre-installed on MAC and most versions of Linux. We have to download it in the case of Windows.
• Here we will learn the Python programming language with
Python 3 (https://www.python.org/downloads/release/python-382/) installed on the computer.
• While learning we will learn to use some symbols/letters in a very special manner.
• While programming, we will use a number of different data types. A data type refers to the type of value an object can have and what operations it performs. The most widely used data type is called a string. Let us call it data type No.1 (String = Data type 1)
• The data represented by String is called alphanumeric data. Alphanumeric data includes both: letters and numbers. If we take an example: “3g7d45kj90”. It is a string of alphanumeric characters.
• Now, let us practice a little bit of coding.
If we want the computer to tell us Hello World!, we will ‘train’ the computer in a specific way, that we can call coding. We will write:
After that, if we use the enter button, the computer we generate:
We should type this on our computer. Remember, (1) don’t write Print, it is print. (2) Don’t forget to use “ ” / ‘ ’ – any of the two. (3) Don’t forget to use ( ) sign.
Let us practice other sentences. To hear from Computer: You are John, We will write
>>>print(“You are John”)
Press enter, you get from the computer:
You are John
If you write:
>>>print(“It is raining today.”)
and press enter, the computer writes:
It is raining today.
The use of a single or double quote symbol communicates to us that “It is raining today.” is a string. Remember that within a string we can use letters, numbers, and spaces randomly without having any meaning. Let us take an example.
>>>print(“5655g6gf6 hhg67fg 7g 8 87h”)
Press enter, you will get:
5655g6gf6 hhg67fg 7g 8 87h
Now, you make at least 5 meaningful sentences. Write the proper code for these 5 sentences and
check whether you are right or wrong.