Download as pdf
Download as pdf
You are on page 1of 1
prince vet") Het worl wth vanable Princes) Conetenaton (smiiring stings) ‘ist rane Gives adits © 4 ik petri fatrare) . en(s) Return the numberof charactersin 8 S-startswith("hel") Test wheter s stars with the substing "hed" Ssendsiith("10") Test whether sends with the substng 1 plus () 4s ()*-Format(3,1,4) Return the string with the values 3,2. and inserted replace(*e","2") Return new svng based fon ewith all occurances of" rapace with “2” Susphit(® ") -spltthestings Into alist of strings, separate onthe character * "and return tat ist eI heer = [rah “rdhin (tine rt tm alt + alae") First bike = bikes) Gettheist tom it tas he = ides -3} Looping tough att prinetttey Making numer! iss stares = C1 fore in rneet, 2) Savors operat en(2)-Retrn the namber of elements 2 sun(2)- Return the sum of the values of ‘in - Retr the minum valve from 2 fpax(2)- Return the maximum vale roms 1L.append(26) -Append the value 36 tothe end of 1 sor8()- Sort the tems in 1in ascending order join({"A","B","C,"0°D) -Convers the Ust [iar.*m","C,"] into the stg "& 8 C0" poo oy feredenton store a ining a massage for cach tom, and a soparaio message atoreards printCvelcane, * + user + *1") srine(Weleane, were glad 9 see you alt") ae fant Copying ast copy of bikes » bikes Making ue Ainensiens = (828, 1888) Looping trough a tule prire(inencton ‘Asmplegitonay ‘Accessing a valie prine(the aber ‘sng 2 new key a paie san('x postion Looping trough a key-value pas {rane rer fn fener ee DPrintnane «iowa er(nawer) Looping tough at keys fav rubers = Cerde': 375 ‘ears 4) mers test) hws 3 other) Looping trough a he values ‘fav prbers = Carte": 17, “ever: 4) Fer murber i for nbers valaes pringetr(nader) 6 7 1a'a favorite?) ‘pen’, ints: 5) calor fs * + alen{*cloe"]) <4. keye()-Retura lst ofthe keys from d 4.values() -Retum a st ofthe values from & 4. tens() -Returna ist of (key, value) pats froma Using a comprehension to generat is of square ombers Agueres = [02 form in rengeC 109] sng 2 lop to conve ist of names to uppercase mes = (hal, ‘abe, voor ames = persnanesppendanetper()) Using a comprehension to convert is f names uppercase anes = [Naty abe!, ada'y Ss", 00") per_nanes = (nane.upber() for name £9 nares] Content (reser than CCondnal es with at Assigning bolean values racine «Te ‘simple test 0 age 20 Pre("Yeu can vote!*) ole sttenents ‘Bcket peice oe let price «30 ichet price = 15 ‘A sinpl function et eet wseeQ) Stipa tne eee. erect asero) Passing an argument et greet. useruserane): ploy personales eeeting.°°* peint('neioy " usewane") ret ase ‘Sesse") Default vals for pramatars ot makes toppinge scan): hea sinee- topping paz prietShve 9s topping» = ize") ste p20) ftkeptzet peer’) Fetrrirg a valve alee aa to nabs an return the en sam a6 ers, 5) rts

You might also like