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



Download 2,61 Mb.
bet31/200
Sana20.06.2022
Hajmi2,61 Mb.
#681748
1   ...   27   28   29   30   31   32   33   34   ...   200
Bog'liq
Python Projects for Beginners A Ten Week Bootcamp Approach to Python

Whitespace


Whitespace just means characters which are used for spacing and have an “empty” representation. In the context of python, it means tabs and spaces. For example:
>>> name = 'John Smith'
There’s whitespace to the left and right of the equals operator. It’s not required, but it makes reading the code easier. The computer simply ignores whitespace when compiling the code. Within the string, however, the space is NOT whitespace, this is simply a “spacing” character.

TUESDAY EXERCISES


  1. Variable Output: store the value 3 in a variable called “x” and the value 10 in a variable called “y”. save the result of x * y into a separate variable called “result”. Finally, output the information so it shows like the following:

>>> 3 + 10 = 13

  1. Area Calculation: Calculate the area of a 245.54” x 13.66” rectangle. print out the result. hINT: Area is width multiplied by height.


Variables are used everywhere, and python makes it easy for us to incorporate them. Being able to store information is a key part of any program. Tomorrow we’ll look at how we can manipulate strings.
Wednesday: Working with Strings
It’s important to understand what you can do with string data types. The next two days cover working with and manipulating strings so that we may build a receipt printing program at the end of the week. We won’t worry about taking in user input but rather how to format strings, what a string index is, etc.
To follow along with this lesson, let’s continue from our previous notebook file
Week_02” and simply add a markdown cell at the bottom that says, “Working with Strings.

String Concatenation


When we talk about concatenating strings, I mean that we want to add one string to the end of another. This concept is just one of many ways to add string variables together to complete a larger string. For the first example, let’s add three separate strings together:

# using the addition operator without variables name = "John" + " " + "Smith" print(name)

Go ahead and run that cell below the markdown cell. The output we get is “John Smith”. We ended up adding two strings that were names and separated them with the use of a string with a space inside. Let’s go ahead and try to store the two names into variables first:

# using the addition operator with variables first_name = "John" last_name = "Smith" full_name = first_name + " " + last_name print(full_name)

Go ahead and run that cell. We get the exact same output as the previous cell; however, we used variables to store the information this time.

Download 2,61 Mb.

Do'stlaringiz bilan baham:
1   ...   27   28   29   30   31   32   33   34   ...   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