-


print_Msg()  subprogram.  The last line “ main()



Download 9,79 Mb.
Pdf ko'rish
bet48/64
Sana16.01.2022
Hajmi9,79 Mb.
#372467
1   ...   44   45   46   47   48   49   50   51   ...   64
Bog'liq
[Nichola Lacey] Python by Example Learning to Pro(1)

print_Msg()
 subprogram. 
The last line “
main()
” is the actual program itself. All this will do is start the 
main()
 
subprogram running. 
Obviously, there is no need to create such a convoluted way of performing what is in fact a 
very simple program, but this is only used as an example of how subprograms are laid out 
and variables can be used and passed between the subprograms. 
Please note:
 Python does not like surprises, so if you are going 
to use a subprogram in a program, Python must have read the 

def subprogram_name()

 
line before so it knows where to 
go to find it. If you try to refer to a subprogram before Python has 
read about it, it panics and will crash. When calling a 
subprogram, the subprogram must be written a
above the section 
of code you use to call it. Python will read from the top down and rrun the first line it comes 
across that has not been indented and does not start with the word def. In the program 
above this would be 
main()
.  
 
 
Remember: never surprise Python as it 
will not like it - good advice for life 
generally.
 
 


Challenges 118 - 123: Subprograms 
1101 
 
 
 
Example Code 
The following examples are all part of the same program and would be displayed in the 
order shown here. 
 
 
 
 
 
 
 
 
 
 
 

Download 9,79 Mb.

Do'stlaringiz bilan baham:
1   ...   44   45   46   47   48   49   50   51   ...   64




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