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



Download 2,61 Mb.
bet27/200
Sana20.06.2022
Hajmi2,61 Mb.
#681748
1   ...   23   24   25   26   27   28   29   30   ...   200
Bog'liq
Python Projects for Beginners A Ten Week Bootcamp Approach to Python

Floats


Anytime a number has a decimal point on it, they’re known as floating point data types. It doesn’t matter if it has 1 digit, or 20, it’s still a float. The primary use of floats is in math calculations, although they have other uses as well. Let’s check out an example:

# the following are all floats print(10.953) print(8.0) # even this number is a float

Go ahead and run the cell. The output should be a series of numbers 10.953 and 8.0.
Note The number “8.0” is considered a float, because it includes a decimal point.

Booleans


The boolean data type is either a True or False value. Think of it like a switch, where it’s either off or on. It can’t be assigned any other value except for True or False. Booleans are a key data type, as they provide several uses. One of the most common is for tracking whether something occurred. For instance, if you took a video game and wanted to know if a player was alive, when the player spawned initially, you would set a boolean
to “True”. When the player lost all their lives, you would set the boolean to “False”. This way you can simply check the boolean to see if the player is alive or not. This makes for a quicker program rather than calculating lives each time. Let’s go ahead and run the following:

# the following are booleans print(True) print(False)

Go ahead and run that cell. The output should be the words True and False, respectively.

Strings


Also known as “String Literals,” these data types are the most complex of the four that we go over today. The actual definition of a string is
Strings in Python are arrays of bytes representing unicode characters.
To most beginners, that’s just going to sound like a bunch of nonsense, so let’s break it down into something simple that we can understand. Strings are nothing more than a set of characters, symbols, numbers, whitespace, and even empty space between two sets of quotation marks. In Python we can use either single or double quotes to create a string. Most of the time it’s personal preference, unless you want to include quotes within a string (see line 3 in the next block). Whatever is wrapped inside of the quotation marks will be considered a string, even if it’s a number. Let’s go ahead and write some examples in the next cell for strings:

# the following are strings
print(" ")
print("There's a snake in my boot!") print('True')

The output will include an empty line at the top, as we print out nothing in the first statement.

Download 2,61 Mb.

Do'stlaringiz bilan baham:
1   ...   23   24   25   26   27   28   29   30   ...   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