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



Download 2,61 Mb.
bet60/200
Sana20.06.2022
Hajmi2,61 Mb.
#681748
1   ...   56   57   58   59   60   61   62   63   ...   200
Bog'liq
Python Projects for Beginners A Ten Week Bootcamp Approach to Python

Copying a List


So how do you create a similar list without altering the original? You copy it! Let’s see how:

# using [:] to copy a list data = [5, 10, 15, 20] data_copy = data[ : ] # a single colon copies the list data[0] = 50 print( "data: { }\t data_copy: { }".format(data, data_copy) )

Go ahead and run that cell. The output this time will result in only our data variable having the first item set to 50. As data_copy was merely a copy of the list, now we’re able to always keep the original list in tact if we need to use it again.

Note

You can also use the method .copy( ).










MONDAY EXERCISES

1.

Sports: define a list of strings, where each string is a sport. then output each sport with the following line “I like to play {}”…

2.

First Character: For the following list, print out each item’s first letter. (output should be ‘J’, ‘A’, ‘S’, ‘K’)
names = [‘John’, ‘Abraham’, ‘Sam’, ‘Kelly’]

today was all about our first data collection type, the list. there was a lot to cover, but it’s important to understand how to define, change values, and make copies of lists.
ChApter 4 LIsts And Loops
Tuesday: For Loops
Today will be spent covering a crucial concept in programming, loops. In most applications, you’re going to need the ability to run the same code more than once. Rather than writing the same lines of code several times, we use loops. In Python there are two types of loops, today’s lesson will be on “For Loops.”
To follow along with this lesson, let’s continue from our previous notebook file
Week_04” and simply add a markdown cell at the bottom that says “For Loops.”

Download 2,61 Mb.

Do'stlaringiz bilan baham:
1   ...   56   57   58   59   60   61   62   63   ...   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