[ERT ICT Teaching] Learning Python for JSS (06 - Making a complete Python program)

preview_player
Показать описание
A complete series of learning python and computational thinking.
Simple enough for junior secondary school students in Hong Kong.
Рекомендации по теме
Комментарии
Автор

Script of this video:
Hi, welcome to Python for Junior Secondary School, lesson 6. I am Mr. Eric Tang. In this lesson, you will learn how to make use of what we've learnt in the previous lessons to write a complete program in Python.

Before we start, lets have a quick revision what a program is. A program in a computer is just a sequence of instructions executed in a pre-defined order. Usually, the instructions will be executed one by one from top to bottom, and sometimes the program will jump back to another steps.

Now, lets open the Python IDLE. This time we don't type in a single instruction and press Enter to execute it immediately, but we want to type in the whole program and then execute the whole program line by line by the computer.

This is the way we do.... Here we go.
Now, we choose File New to open an editor and you will see there is a new editing window for us to type in the whole program.

type our Python program together now.

( # 3Xxx_note01_prog01.py )
A pound sign... and then 3Xxx where the Xs represent your class and class number and then underscore underscore Enter

This is something new. The words after the pound sign in Python are called comments (Write on the screen) the computer will ignore them. It is just for your own reference, therefore, you can type in anything after the pound sign. You need to write your own comments in a program because sometimes you might forget what you want to do at that points after you have written a thousand of lines. This is always a good practice to write comments in a program to drop down some important notes yourself.


Then another comment:
# This is my first program... Enter

Then
math_mark=60...Enter
Then
chi_mark=70... Enter
Then
eng_mark=90... Enter

Ok you just created three variables to store the marks of different subjects. Then you can do some operations and on them .

This is a simple program to output the average marks of three subjects.

Lets type in:
print('Average Mark is :', (math_mark + chi_mark + eng_mark)/3)

You can see here, this print statement will print out two things on the screen. The first one is the text string "Average Mark is: as we have mentioned in lesson 4, everything between double quotation marks here are texts.... here in the print statement, there is a comma, it means after there is another thing to output, this time it is the result of the values of the variables math_mark plus chi_mark plus eng mark and then divided by 3.

Ok. We have just finished written the program and we want to save it in a text file. You can now press File as you type in a file name, .. you will type in 3Xxx where xxx is your class and class number, underscore note01 underscore prog01, select a folder to I choose and the press It's done!

Lets' run the program by choosing and then Run

It works!

Ok. Now I close the suppose next time you want to open this program for editing again, you can in IDLE choose File File open select the file again It's done!

Ok. That's enough for today! Please finish the question in the Go Formative system! If you like this video, please give me a LIKE. Goodbye!

ertxxx
visit shbcf.ru