Location via proxy:
[ UP ]
[Report a bug]
[Manage cookies]
No cookies
No scripts
No ads
No referrer
Show this form
Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
374 views
Python Data Structure Assignment
Uploaded by
Akshay Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Python Data Structure Assignment For Later
Download
Save
Save Python Data Structure Assignment For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
374 views
Python Data Structure Assignment
Uploaded by
Akshay Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Python Data Structure Assignment For Later
Carousel Previous
Carousel Next
Save
Save Python Data Structure Assignment For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 9
Search
Fullscreen
11317, 152 PM 5..Python Data Structure Assignment Day 5 done.ipynb - Colaboratory Python Data Structures Types of Data Structures: eo posible yee aloned 1D snmutable => can't be changes ‘D mutable => can be changed Lists Create an empty list with the name a, print the value of a and type(a). = printtay 0 f print the type of @ Type) Create a list , languages = [R,Python, ‘SAS, ‘Scala’, 42] Pint the numberof elements inthe ist pranteay [oR “Python, “S88, “Seata', 2] Using for loop iterate and print all the elements in thelist, ntps:ifeolab rosearch google. comldrva/t OKBOSTIm7UoOxhgeTOyITETRBSVoolprintModo=tue 19‘191723, 1:62 PM 5..Python Data Structure Assignment Day 5 done ipynb - Colaboratory Select the second tem, Pythar and store it in new variable named Yemg! senpet emp-insert(2,"Pythan") Print the value of temp and type(temp) print(tenp) Sypet tere) [erython ‘Append the element Java’ inthe list senp.sppene("3a¥8") print(eenp) [Python's “3ava") Remove the element 42 frm the lit and print the ist ssrenove( 42) Create a list, colors = [Red’, ‘Blue’, White] colors = {ed Blue’, ite") Append the element Black to colors colors. sppend(“blaee") print(colors) [red', “olue', “white’, “slack*] [Append the color ‘Orange! to second position (index=1) and print the Uist colors. insere(a,"orange") Print the ist print(colors) [rRed', ‘orange’, “slue', “wnite", ‘alack') Create another ist, colors2 = (Grey, ‘Sky Blue] colors2=("Grey' "Sty Blue") [Add the elements af colors? to colors using extend function inthe list ntps:ifeolab rosearch google. comldrva/t #OKBOSTIm7UodxhgeTOyITETRDSVoolprintModo=tue‘191723, 1:62 PM 5..Python Data Structure Assignment Day 5 done ipynb - Colaboratory celors.entend(colors2) Printlen of colors ands elements x = den(coters) print x print(colors) [rted', ‘orange’, ‘Slue', “white, “alack', “rey', ‘sky olue') Sort the list and print it celors.sort() print(colors) [blace’, “blue, “Grey's orange’, ‘Rea, “Shy Blu0", “unite Create a string, sent = ‘Coronavirus Caused Lockdowns Around The World.” Use split function to convert the string int alist of words and save it invariable words and print he same 5 = sent splie() printce) coronavirus", “Causes, “Lockdouns!, ‘Argun, "The’y “hone. *] Convert each word in the list to lower case and store itn vaiable words lower. Print words lower words_lower = sent. lower) print(woeds_tower) ‘Check whether eounty'is inthe list praret found") Prine (not found") Remove the element ‘the’ from the list and print thelist. evrenove("The") pranteey coronavirus", “Caused, “Loekdouns', “Around, “Wort Select the fst 4 words fom the Ist words Jower using sleing and store them In a new variable x4 ntps:ifeolab rosearch google.comldrva/t #OKBOSTim7UodxhgeTOyITETRBSvoolprintMode=tue11317, 152 PM 5..Python Data Structure Assignment Day 5 done.ipynb - Colaboratory Ht = words_lower{@:-10] Convert the ist of elements to single string using jin function and print it sointey Sets Create stud_grades = [AB stad.grades © [A148 Print the len of stud grades x= ten(stus graces) prints) Create a new variable, stud_grades_set = set(stuc.grades) stud grades_set = set(stud_grades) Print stud. grades. set print(stud_grades_set) CAC, OOD print the type of stue_grades and stud_grades_set and print their corresponding elements, Try to understane the difference between them, [Add a new element’6'to stud_grades_set stu grades set.24a0"6") ‘Add element 'F'to stud. grades_set. and print stad_ grades. set. add") ntps:ifeolab rosearch google. comldrva/t #OKBOSTim7UodxhgeTOyITETRBSVoolprintMode=tue 49‘191723, 1:62 PM 5..Python Data Structure Assignment Day 5 done ipynb - Colaboratory "Dd you notice? set doesn't ade an element iit’ already present init untke ist, Remove'F from stud grades_set stud_grades_set.renove("E*) Print the elements and the length of stud. grades. set print(stud_grades_set lent stu Create colors = [red'/blue‘orangel], and fruits ‘orange'/grapes'/apples] colors = [Cred blue’, “arange"] fruits = (orange, “grapes, apples") Print color and fut print{ colors, fruits) [rred', “olue', ‘orange’) [Vorange’, “erapes', ‘apples") Create colors. set, and fruts_set. (using set()) and pin them set( (rea, “atu, orange’) set(Corange’ "grapes" apples) print(colors_set,(ruits_set) Find the union of both the sets 2 = colons. set-unton(sreits_set) Print(2) Find the intersection of bath the sets 1 = colors_set-tntersection( fruite set) printte) range") Find the elements which are Fut but not colors (using set.ference()) a> frusts_set.titterence( colors se8) print¢e) ntps:ifeolab rosearch google. comldrva/t OKBOSTIm7UoOxhgeTOyITETRBSVoolprintModo=tue 59‘191723, 1:62 PM 5..Python Data Structure Assignment Day 5 done ipynb - Colaboratory grapes", “apples'} TUPLES. Create temp =[17, 'Virat’, 50.0] temp = (17, ‘Virat', $0.0] Iterate through temp and print all the items in temp print(senp) 27, “vieat’, 50.9) replace fist element with 1 in temp Settempl = tuple(temp) senpt = tuplatene) IRerate through tempt and print al the items in tempt prant¢ceno2) at, 50.0) replace fist element with 17 in temp? emp = ist(terpt) enp{0) = 17 fenpt = tuplatene) print(cenoa) (27, “vies, 50.0) ‘Oopst! You got an error. Hey Dorit wory!Its because Once a tuple i create you cannot change its values unlike Hist. Create city Bangalore’, 28.9949521, 72) clty = ("Banestore, 28.989521, 72) Print frst element of ty print¢etty) (angatore’, 28.9949521, 72) ntps:ifeolab rosearch google. comldrva/t #OKBOSTim7UodxhgeTOyITETRDSVoolprintModo=tue11317, 152 PM 5..Python Data Structure Assignment Day 5 done.ipynb - Colaboratory Create city2 = (Chennal, 30.01, 74) citye = Cebeanaé!, 38.01, 74) Create cities which consist of ety and city? Print etes print(essses) (Bangaiore’, 28.9949521, 72, ‘Chennai’, 38.01, 74) Print typeof fst element in cities synet0) Print the type of ces cypetesties) Hey that implies you made a nested tuples! DICTIONARY Create a dictionary d = ('actor"amir’‘animal 4 = Cactor*s"anie”,“aninan"s"eat®,Yearen:2, "Lists (23,32,22]}, Print the value of do) print(a.vatues(0)) (Oopst! again an error. again a fun fact, Ditionary return the value for key if key is in the detionay, here Store the value of dfactor to anew variable actor. actor = d.get ("acter") ntps:ifeolab rosearch google. comldrva/t #OKBOSTim7UodxhgeTOyITETRDSVoolprintModo=tue ‘cat’ yearth’:2"list"[23,32,12]) 1 throws KeyError and we don't have key 119‘191723, 1:62 PM Print the typeof actor sypetaetor) Store the value of ast] is List = a.get(rtise”) (2, 32, a2) Print the typeof List eypettisty create di eke ( singer” 2 ke Merge dt into d apdatetat) ctor’: ante’, ist": (23, 32, 1 5..Python Data Structure Assignment Day 5 done ipynb - Colaboratory in new variable List. ‘singe’: KrSna’, ‘album Still here, genre hip-hop) fatbun's “SEIT here’, “genre” + “hipstop") pinta print(e) Print althe keys in print(a.kays()) ict keys(U'actor", Print all he values ind print¢s.values()) de yates ({'anse Iherate over d and pent ea animal's cat’, ‘earth's 2, ‘Issn: (23, 32, 12], ‘singe’: Skefna", ‘albon's °SesI0 here’, ‘animal’, ‘earth’, “List", “singer', ‘alban’, “gsnre'1) "eat 2, (28, 32, 12], “egma", “SEH here", “hép=hop" D> ich key, value pair as this ( tor —> ami) ey, "9 aleey1 ) ee. (3, 32, 12) singer > tna ntps:ifeolab rosearch google. comldrva/t #OKBOSTim7UodxhgeTOyITETRDSVoolprintModo=tue a9‘191723, 1:62 PM 5..Python Data Structure Assignment Day 5 done ipynb - Colaboratory count the number of accurences of charachters in string named "sent using dictionary and print the same Gi = (1 sent.count(x) for in set(sent)) print(at) ntps:ifeolab rosearch google. comldrva/t #OKBOSTim7UodxhgeTOyITETRBSVoolprintMode=tue 919
You might also like
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Mark Manson
4/5 (6124)
Principles: Life and Work
From Everand
Principles: Life and Work
Ray Dalio
4/5 (627)
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Brené Brown
4/5 (1148)
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
Chris Voss
4.5/5 (933)
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Jeannette Walls
4/5 (8214)
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Angela Duckworth
4/5 (631)
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
Jesmyn Ward
4/5 (1253)
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Stephen Chbosky
4/5 (8365)
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Phil Knight
4.5/5 (860)
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Carmen Maria Machado
4/5 (877)
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
Margot Lee Shetterly
4/5 (954)
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Ben Horowitz
4.5/5 (361)
Steve Jobs
From Everand
Steve Jobs
Walter Isaacson
4/5 (2922)
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
Ashlee Vance
4.5/5 (484)
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Siddhartha Mukherjee
4.5/5 (277)
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
Colm Toibin
3.5/5 (2061)
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Fredrik Backman
4.5/5 (4972)
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Frank McCourt
4.5/5 (444)
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
Garth Stein
4/5 (4281)
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
Sarah M. Broom
4/5 (100)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
Meik Wiking
3.5/5 (447)
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Thomas L. Friedman
3.5/5 (2283)
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
Roxane Gay
4/5 (1068)
Yes Please
From Everand
Yes Please
Amy Poehler
4/5 (1987)
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
Gilbert King
4.5/5 (278)
The Outsider: A Novel
From Everand
The Outsider: A Novel
Stephen King
4/5 (1993)
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
Ruth Ware
3.5/5 (2619)
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
Betty Smith
4.5/5 (1936)
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
Viet Thanh Nguyen
4.5/5 (125)
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Doris Kearns Goodwin
4.5/5 (1912)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Dave Eggers
3.5/5 (692)
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
Hilary Mantel
4/5 (4074)
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Naomi Klein
4/5 (75)
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Bob Woodward
3.5/5 (830)
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Jay Sekulow
3.5/5 (143)
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
Jennifer Egan
3.5/5 (901)
John Adams
From Everand
John Adams
David McCullough
4.5/5 (2530)
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
M L Stedman
4.5/5 (790)
New - SQL Qustions
PDF
No ratings yet
New - SQL Qustions
3 pages
Car Details From Car Dekho
PDF
No ratings yet
Car Details From Car Dekho
212 pages
Zivame Planning Analyst Excel SQL Test
PDF
No ratings yet
Zivame Planning Analyst Excel SQL Test
50 pages
Untitled Spreadsheet
PDF
No ratings yet
Untitled Spreadsheet
3 pages
Linear Reg 1
PDF
No ratings yet
Linear Reg 1
7 pages
Life Expectancy Data
PDF
No ratings yet
Life Expectancy Data
288 pages
Car Data
PDF
No ratings yet
Car Data
16 pages
Statistics Assignemt
PDF
100% (1)
Statistics Assignemt
19 pages
EDA Assignment
PDF
No ratings yet
EDA Assignment
16 pages
Pandas Assignment
PDF
100% (2)
Pandas Assignment
11 pages
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
George Packer
4/5 (45)
Little Women
From Everand
Little Women
Louisa May Alcott
4/5 (105)
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel
John le Carré
3.5/5 (109)
Related titles
Click to expand Related Titles
Carousel Previous
Carousel Next
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Principles: Life and Work
From Everand
Principles: Life and Work
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Steve Jobs
From Everand
Steve Jobs
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
Yes Please
From Everand
Yes Please
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
The Outsider: A Novel
From Everand
The Outsider: A Novel
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
John Adams
From Everand
John Adams
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
New - SQL Qustions
PDF
New - SQL Qustions
Car Details From Car Dekho
PDF
Car Details From Car Dekho
Zivame Planning Analyst Excel SQL Test
PDF
Zivame Planning Analyst Excel SQL Test
Untitled Spreadsheet
PDF
Untitled Spreadsheet
Linear Reg 1
PDF
Linear Reg 1
Life Expectancy Data
PDF
Life Expectancy Data
Car Data
PDF
Car Data
Statistics Assignemt
PDF
Statistics Assignemt
EDA Assignment
PDF
EDA Assignment
Pandas Assignment
PDF
Pandas Assignment
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
Little Women
From Everand
Little Women
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel