Python in Education


  |  Chapter 2: A Pythonic Case Study: Raspberry Pi



Download 3,73 Mb.
Pdf ko'rish
bet19/37
Sana01.01.2022
Hajmi3,73 Mb.
#303345
1   ...   15   16   17   18   19   20   21   22   ...   37
Bog'liq
Python in Education (en)

12  |  Chapter 2: A Pythonic Case Study: Raspberry Pi


CHAPTER 3

Why Python in Education?

I am going to answer a very simple question: which features of the

Python language 

itself

 make it appropriate for education? This will

involve learning a little Python and reading some code. But don’t

worry if you’re not a coder! This chapter will hopefully open your

eyes to how easy it is to learn Python (and thus, why it is such a pop‐

ular choice as a teaching language).



Code Readability

When I write a to-do list on a piece of paper, it looks something like

this:

Shopping


Fix broken gutter

Mow the lawn  

This is an obvious list of items. If I wanted to break down my to-do

list a bit further, I might write something like this:

Shopping:

    Eggs


    Bacon

    Tomatoes

Fix broken gutter:

    Borrow ladder from next door

    Find hammer and nails

    Return ladder!

Mow the lawn:

    Check lawn around pond for frogs

    Check mower fuel level 

13



Intuitively we understand that the main tasks are broken down into

sub-tasks that are indented underneath the main task to which they

relate. This makes it easy to see, at a glance, how the tasks relate to

each other.

This is called scoping.

Indenting in this manner is also how Python organizes the various

tasks defined in Python programs. For example, the following code

simply says that there is a function called 

say_hello

 that asks the

user to input their name, and then—you guessed it—prints a

friendly greeting:

def say_hello():

    name = input('What is your name? ')

    print('Hello, ' + name)

Here’s this code in action (including my user input):

What is your name? Nicholas

Hello, Nicholas  

Notice how the lines of code implementing the 

say_hello

 function

are indented just like the to-do list. Furthermore, each instruction in

the code is on its own line. The code is easy to read and understand:

it is obvious which lines of code relate to each other just by looking

at the way the code is indented.

Most other computer languages use syntactic symbols rather than

indentation to indicate scope. For example, many languages such as

Java, JavaScript and C use curly braces and semicolons for this pur‐

pose.

Why is this important?



If, like me, you have taught students with English as an additional

language or who have a special educational need such as dyslexia,

then you will realize that Python’s intuitive indentation is something

people the world over understand (no matter their linguistic back‐

ground). A lack of confusing symbols such as '{', '}' and ';' scattered

around the code also make it a lot easier to read Python code. Such

indentation rules also guide how the code should look when you

write it down—the students intuitively understand how to present

their work.

Compared to most other languages, Python’s syntax (how it is writ‐

ten) is simple and easy to understand. For example, the following


Download 3,73 Mb.

Do'stlaringiz bilan baham:
1   ...   15   16   17   18   19   20   21   22   ...   37




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish