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



Download 2,61 Mb.
bet37/200
Sana20.06.2022
Hajmi2,61 Mb.
#681748
1   ...   33   34   35   36   37   38   39   40   ...   200
Bog'liq
Python Projects for Beginners A Ten Week Bootcamp Approach to Python

Initial Process


Whenever you begin a project, you must always understand where to start. No matter the size of the project, there are certain dependencies. Like building a house, you must have a foundation before you can put the roof on. Now, this program will be around 50 lines and have little to no dependencies, so we’ll start with the top border and work our way down to the bottom.

Defining Our Variables


In the cell below our markdown header, let’s begin to define the variables that we’ll be working with throughout this program:

1| # create a product and price for three items
2| p1_name, p1_price = "Books", 49.95
3| p2_name, p2_price = "Computer", 579.99
4| p3_name, p3_price = "Monitor", 124.89

I always like to introduce new concepts while building out these Friday projects, as it’s good to implement good coding techniques. The technique introduced within this block is the ability to declare multiple variables on the same line. To do so, we simply separate the variable names and their associated values by a comma. Looking at the first two variables declared, the value of “Books” will be saved into the variable name
p1_name”, and the value “49.95” will be saved into the variable name “p1_price”. Rather than writing six lines, we’ve reduced our program by half already. The less lines we use the better (most times). Variables such as x and y, or in our case, a name and price, are good examples of declaring variables associated together in one line.
Next, let’s define the variables we’ll be using for the company at the top of the receipt. All the code for this project may be done in a single cell, or you can separate the cells. It’s up to you. I’ve provided line numbers in case you follow along on a single cell:

6| # create a company name and information
7| company_name = "coding temple, inc."
8| company_address = "283 Franklin St."
9| company_city = "Boston, MA"

As an example, we’ve left the company name all lowercase so that we can use a string manipulation method to fix this issue.
Lastly, let’s declare the message that we’ll output to the user at the bottom of the receipt:

11| # declare ending message
12| message = "Thanks for shopping with us today!"

Go ahead and run the cell. Now that we’ve defined all our variables, we can move on.

Download 2,61 Mb.

Do'stlaringiz bilan baham:
1   ...   33   34   35   36   37   38   39   40   ...   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