Kandungan dihapus Kandungan ditambah
|
|
{{Nota penterjemah|Ingat, Python hanya boleh berbahasa Inggeris. Itu sebab dalam outputnya, Python mengeja bulan dan hari dalam bahasa itu}}
(ISaya skippedmengabaikan somesebahagian of thedaripada output, buttapi Isaya thinkfikir youanda getdapat the ideabayangannya.) SoJadi, whatapa doesyang thedilakukan oleh program doini? Baris The first linepertama <code>import calendar</code> usesmengguna aperintah new commandbaharu, <code>import</code>. The commandPerintah <code>import</code> loadsmemuatkan a modulemodul (indalam thiskes caseini themodul <code>calendar</code> module). ToUntuk seemelihat theperintah-perintah commandsyang availableterdapat indalam themodul-modul standard, moduleslihat eitherdalam lookrjukan in the library reference forperpustakaan python (ifsekiranya youanda downloadedmemuat itturunnya) oratauapun pergi goke to http://docs.python.org/library/. IfJika youanda lookmelihat atdokumentasi thebagi documentation for themodul <code>calendar module</code>, itia listsmenyenaraikan asebuah functionfungsi calledbergelar <code>prcal</code> thatyang printsmencetak akalendar calendarbagi for a yearsetahun. The lineBaris <code>calendar.prcal(year)</code> usesmengguna thisfungsi functionini. Secara Inringkas, summaryuntuk tomengguna use amodul, moduleguna <code>import</code> ituntuk andmengimportnya thendan usekemudian guna <code>module_name.function<code> forbagi functionsfungsi-fungsi indalam themodul moduleitu. Cara Anotherlain wayuntuk tomenulis writeprogram the programini isialah:
<source lang="python">
from calendar import prcal
yeartahun = input("TypeTaipkan innombor the year numbertahun: ")
prcal(yeartahun)
</source>
|