nouha-thabet python-lists-part-ii-and-tuples

До загрузки: 30 сек.



Благодарим, что скачиваете у нас :)

Если, что - то:

  • Поделится ссылкой:
  • Документ найден в свободном доступе.
  • Загрузка документа - бесплатна.
  • Если нарушены ваши права, свяжитесь с нами.
Формат: pdf
Найдено: 04.06.2020
Добавлено: 30.09.2020
Размер: 0.05 Мб

Pyth on L is ts - P art II & T uple s C heat S heet
by
Nouha_T habet
v ia
ch eato gra phy.c o m /1 03894/c s/2 1345/
C opy a L is t
RYB_color = ["Re
​d","Y
​ell
​ow",
​Blu
​e"]

E xam ple 1

Copy_RYB = RYB_color.copy()
E xam ple 2

Copy_RYB = list(R
​YB_
​color)
Jo in T w o L is ts
RYB_color = ["Re
​d","Y
​ell
​ow",
​Blu
​e"]
Second
​_color = ["Gr
​een
​" ​,"Or
​ang
​e","P
​urp
​le"]

E xam ple 1

RYB_S
​econd = RYB_co
​lor.ex
​ten
​d(S
​eco
​nd_
​color)

E xam ple 2

RYB_S
​econd = RYB_color + Second
​_color
The lis t() C onstr
​ucto r
RYB_color = list((
​" ​Red
​" ​,"Ye
​llo
​w",B
​lue
​"))
Tuple
A tu ple is a c o lle ctio n w hic h is o rd ere d a nd u nch an
​geable . In P yth on
tu ple s a re w rit te n w it h r o und b ra cke ts .
Tuple E xam ple
RYB_color = ("Re
​d","Y
​ell
​ow",
​" ​Blu
​e")
print(
​RYB
​_color)
>>>
​('R
​ed'
​,'Y
​ell
​ow'
​,'B
​lue')
A ccess T uple It e m s
S am e a s a cce ss lis t it e m s. P le ase c h eck "
​Acce ss lis t it e m s" in "
​‐
P yth on L is ts - P art I" c h eat s h eet.
C han ge T uple V alu es
S in ce tu ple s a re in ch an
​geable , th en w e c a nnot c h ange a ny v a lu e.
B ut, w e c a n c o nve rt a tu ple to a lis t, c h ange th e v a lu es th at w e w ant
w it h in th e lis t a nd
co nve rt th e lis t b ack in to a tu ple .
E xam ple
`RYB_
​color = ("Re
​d","Y
​ell
​ow",
​" ​Blu
​e")
L = list(R
​YB_
​color)
L[0] = "
​Mag
​ent
​a"
RYB_color = tuple(X)
Check if It e m E xis ts
Sam e a s c h eckin g it e m w it in a lis t . P le ase c h eck "
​Check if Ite m
Exis ts
​" in "
​Pyth on L is ts - P art I" c h eat s h eet.
Tuple L en gth
Sam e a s lis t le ngth . P le ase c h eck " L is t L ength
​" in "
​Pyth on L is ts -
Part I" c h eat s h eet.
Add It e m s
Once a tu ple is c re ate d, w e c a nnot a dd it e m s to it . T uple s a re
unch an
​geable .
Cre ate T uple W it h O ne It e m
To c re ate a tu ple w it h o nly o ne it e m , w e h ave a dd a c o m ma a fte r th e
it e m , u nle ss P yth on w ill n ot r e co gniz e th e v a ria ble a s a tu ple .
Color = ("Wh
​ite
​",)
Rem ove It e m s
Tuple s a re u nch an
​geable , s o w e c a nnot r e m ove it e m s fr o m it , b ut
we c a n d ele te th e tu ple c o m ple
​te ly .
RYB_color = ("Re
​d","Y
​ell
​ow",
​" ​Blu
​e")
del RYB_color
Jo in T w o T uple s
RYB_color = ("Re
​d","Y
​ell
​ow",
​" ​Blu
​e")
Second
​_color = ("Or
​ang
​e","G
​ree
​n","P
​urp
​le")
RYB_Second = RYB_color + Second
​_color
The t u ple () C onstr
​ucto r
RYB_co lo r = tu ple (
​(" R e
​d"," Y
​ell
​ow ",
​" ​Blu
​e"))
By
Nouha_T hab et
ch eato gra phy.c o m /n ouha-
th abet/
Publis h ed 7 th D ece m ber, 2 019.
Last u pdate d 7 th D ece m ber, 2 019.
Page 1 o f 1 .
Sponso re d b y
Cro ssw ord C heats .c o m
Learn to s o lv e c ry p tic c ro ssw ord s!
http ://c ro ssw ord ch eats .c o m

Сообщить о нарушении / Abuse

Все документы на сайте взяты из открытых источников, которые размещаются пользователями. Приносим свои глубочайшие извинения, если Ваш документ был опубликован без Вашего на то согласия.