Professional IronPython



Download 20,35 Mb.
Pdf ko'rish
bet71/453
Sana01.07.2022
Hajmi20,35 Mb.
#723045
1   ...   67   68   69   70   71   72   73   74   ...   453
LISTINg 3-4: 
 Making complex decisions
# Define an input variable.
Answer = raw_input(‘Say hello (Y/N)?’)
# Check the value of Answer.
if Answer.upper() == ‘Y’:
# Perform some tasks based on a positive response.
print ‘You typed:’, Answer
print ‘So Hello!’
# Check to see if the user entered N
elif Answer.upper() == ‘N’:
# Give a reponse for a negative answer.
print ‘Sorry to hear you don\‘t want to say hello.’
# The user must have typed something else.
else:
# Perform some tasks based on a different response.
print ‘You need to type Y or N!’
# Pause after the debug session.
raw_input(‘Press any key to continue...’)
LISTINg 3-3 
(continued)
548592c03.indd 50
2/24/10 12:47:30 PM
www.finebook.ir


Creating Loops
 

 
51
As you can see from the code, the 
elif
clause looks very much like the 
if
clause. The only differ-
ence is that the 
elif
clause must follow the 
if
clause. You can include as many 
elif
clauses as 
required to perform a particular task. The output from this example is similar to that shown in 
Figure 3-2.
CREATINg LooPS
Computers are far better at repetitive tasks than humans. A computer will perform the same task as 
long as you want it to. In fact, your computer is currently performing tasks repetitively, even if you 
didn’t start those tasks. For example, you probably have a firewall that’s looking for terrifying inputs 
from outside sources, using some type of repetitive procedure. Applications handle these repetitive 
tasks using loops. IronPython provides two kinds of loops as described in the following sections:

for...in

while



Download 20,35 Mb.

Do'stlaringiz bilan baham:
1   ...   67   68   69   70   71   72   73   74   ...   453




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