Python in Education


  |  Chapter 3: Why Python in Education?



Download 3,73 Mb.
Pdf ko'rish
bet23/37
Sana01.01.2022
Hajmi3,73 Mb.
#303345
1   ...   19   20   21   22   23   24   25   26   ...   37
Bog'liq
Python in Education (en)

16  |  Chapter 3: Why Python in Education?


summing a dictionary and a list?). Here’s what the ubiquitous Java‐

Script language will do when you attempt to add the equivalent data

structures (in JavaScript parlance, an object '{}' and an array '[]'):

> {} + []

Of course, the answer is obviously zero!?!



Guess what happens if you try to sum an empty array with an object

in JavaScript (we switch around the summed terms).

> [] + {}

"[object Object]"

I bet you were expecting a consistent result!

(Again, the caveat of JavaScript having a different set of aims and

objectives to Python should be applied here.)

Learning, by its very nature, involves making mistakes and realizing

that mistakes have been made. Only then can behavior be adjusted

and progress made. If you’re learning to program using a language

like JavaScript (that would rather make what appears to be a best

guess at what you mean, rather than complain about an obvious

error), then all sorts of mistakes will pass by unnoticed. Instead,

you’ll either continue in your mistaken view of the programming

world or you’ll have to understand the rather complex and tortuous

rules that JavaScript uses to cause 

{} + []

 to equal 

0

 and 


[] + {}

 to


equal 

"[object Object]"

 (itself, a difficult educational feat to pull

off).


Python’s simplicity and obviousness encourages learners and profes‐

sional developers alike to create understandable code. Understanda‐

ble code is easier to maintain and less likely to contain bugs (because

many bugs are caused by 



misunderstanding what the code is actually

doing

 compared to what you 



mistakenly think it ought to be doing

).

Being able to simply state your ideas in code is a very powerful and



empowering capability.

For example, consider an old-school text adventure game. Players

wander around a world consisting of locations that have descrip‐

tions and exits to other locations. The program below very clearly

and simply implements exactly that.

Most of the program consists of either comments to explain how it

works or is a data dictionary that describes the game world. It is only


Download 3,73 Mb.

Do'stlaringiz bilan baham:
1   ...   19   20   21   22   23   24   25   26   ...   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