Python Projects for Beginners a ten-Week Bootcamp Approach to Python Programming



Download 2,61 Mb.
bet48/200
Sana20.06.2022
Hajmi2,61 Mb.
#681748
1   ...   44   45   46   47   48   49   50   51   ...   200
Bog'liq
Python Projects for Beginners A Ten Week Bootcamp Approach to Python

TUESDAY EXERCISES


1. Checking Inclusion – Part 1: Ask the user for input, and check to see if what they wrote includes an “es”.
2 . Checking Inclusion – Part 2: Ask the user for input, and check to see if what they wrote has an “ing” at the end. Hint: Use slicing.

  1. Checking Equality: Ask the user to input two words, and write a conditional statement to check if both words are the same. Make it case insensitive so that capitals do not matter.

  2. Returning Exponents: Ask for the user to input a number, and return that number squared if it is lower than 10. Hint: Investigate arithmetic expressions for exponents.


Today was an important lesson on conditional statements. having the ability to let the computer make decisions and perform an action based off them is an important key to any program.
Wednesday: Elif Statements
Conditional statements give us the power to make decisions in our program, but so far, we’ve only seen a glimpse of the capabilities that we have with them. Today, we’ll be learning all about elif statements. They give us the ability to run separate blocks of code depending on the condition. They are also known as “else if statements.
To follow along with this lesson, let’s continue from our previous notebook file
Week_03” and add a markdown cell at the bottom that says, “Elif Statements.

How They Work


As we saw in the previous lesson, conditional statements give us the ability to make decisions within our program; however, how would you handle making multiple decisions? In Python, we use the elif statement to declare another decision based on a given condition. Elif statements must be associated with an if statement, meaning that you cannot create an elif without an if. Python works in top to bottom order, so it checks the first if statement; if that statement is False, it continues to the first elif statement and checks that condition. If that condition returns False as well, it continues to the next conditional statement until there are no more to check. However, once a single conditional statement returns True, all other conditionals are skipped, even if they are True. It works so that the first conditional to return True is the only block of code that runs.

Download 2,61 Mb.

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




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