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)
519 views
9 pages
Python Data Structure Assignment
Uploaded by
Akshay Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save Python Data Structure Assignment For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
519 views
9 pages
Python Data Structure Assignment
Uploaded by
Akshay Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save Python Data Structure Assignment For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save Python Data Structure Assignment For Later
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
List in Python Final
PDF
No ratings yet
List in Python Final
40 pages
Iti Copa Python MCQ
PDF
No ratings yet
Iti Copa Python MCQ
15 pages
Unit 5 - 1. File Handling in Python
PDF
No ratings yet
Unit 5 - 1. File Handling in Python
36 pages
Pandas Assignment
PDF
100% (2)
Pandas Assignment
11 pages
Python Data Structures Cheat Sheet
PDF
No ratings yet
Python Data Structures Cheat Sheet
1 page
Mysql Full Notes
PDF
No ratings yet
Mysql Full Notes
41 pages
Python Assignment
PDF
33% (3)
Python Assignment
53 pages
Data Types in Python
PDF
No ratings yet
Data Types in Python
5 pages
Unit 4
PDF
No ratings yet
Unit 4
60 pages
Unit 1
PDF
100% (1)
Unit 1
69 pages
Ch05 - Python - Data Structures - 1721754633
PDF
No ratings yet
Ch05 - Python - Data Structures - 1721754633
37 pages
If - Else - Worksheet (Class 11)
PDF
No ratings yet
If - Else - Worksheet (Class 11)
4 pages
python-notes-BCC-302 (Unit - 05)
PDF
No ratings yet
python-notes-BCC-302 (Unit - 05)
25 pages
NumPy Notes
PDF
No ratings yet
NumPy Notes
13 pages
Unit 1 - Data Handling Using Pandas and Data Visualisation: Important Multiple Choice Questions
PDF
No ratings yet
Unit 1 - Data Handling Using Pandas and Data Visualisation: Important Multiple Choice Questions
6 pages
12cs Ernakulam SQP 2223 Solved QP
PDF
No ratings yet
12cs Ernakulam SQP 2223 Solved QP
68 pages
Raptor Labs
PDF
No ratings yet
Raptor Labs
21 pages
Data Wrangling
PDF
No ratings yet
Data Wrangling
13 pages
Grade 12 - Data Handling Using Pandas 1-Worksheet 1
PDF
No ratings yet
Grade 12 - Data Handling Using Pandas 1-Worksheet 1
2 pages
Data Handling Using Pandas-1
PDF
No ratings yet
Data Handling Using Pandas-1
25 pages
Unit 6 - List, Tuples and Dictionary: Objectives
PDF
No ratings yet
Unit 6 - List, Tuples and Dictionary: Objectives
21 pages
Solutions To Python by S Arora
PDF
58% (64)
Solutions To Python by S Arora
12 pages
List, Tuple, and Dictionaries
PDF
No ratings yet
List, Tuple, and Dictionaries
15 pages
Chapter 2 - NumPy and Pandas
PDF
No ratings yet
Chapter 2 - NumPy and Pandas
26 pages
Chapter 6 Database
PDF
No ratings yet
Chapter 6 Database
67 pages
Class - Xii-Mysql and It Application Notes
PDF
No ratings yet
Class - Xii-Mysql and It Application Notes
36 pages
Python
PDF
No ratings yet
Python
157 pages
03 Strings in Python
PDF
No ratings yet
03 Strings in Python
29 pages
UNIT 1 - Array Based Implementation
PDF
No ratings yet
UNIT 1 - Array Based Implementation
19 pages
Python Lab Exercise 1-10
PDF
No ratings yet
Python Lab Exercise 1-10
12 pages
Advance Python Question Paper 2023
PDF
No ratings yet
Advance Python Question Paper 2023
2 pages
Python Assignment
PDF
100% (1)
Python Assignment
4 pages
W3school Numpy
PDF
No ratings yet
W3school Numpy
9 pages
Car Data
PDF
No ratings yet
Car Data
16 pages
Typecasting in Python
PDF
No ratings yet
Typecasting in Python
6 pages
On MYSQL COMMANDS
PDF
No ratings yet
On MYSQL COMMANDS
9 pages
MCQ
PDF
No ratings yet
MCQ
22 pages
Python modules-XI
PDF
No ratings yet
Python modules-XI
9 pages
Python Question and Answers - Built-In Functions - 1
PDF
0% (1)
Python Question and Answers - Built-In Functions - 1
15 pages
Strings PDF
PDF
No ratings yet
Strings PDF
14 pages
DBMS Lab Paper
PDF
100% (1)
DBMS Lab Paper
5 pages
Tuple in Python PDF
PDF
No ratings yet
Tuple in Python PDF
20 pages
Python Revision Tour
PDF
No ratings yet
Python Revision Tour
14 pages
Life Expectancy Data
PDF
No ratings yet
Life Expectancy Data
288 pages
Python Interview Questions
PDF
No ratings yet
Python Interview Questions
8 pages
File Handling in R Programming: Eg: File - Create ("GFG - TXT")
PDF
No ratings yet
File Handling in R Programming: Eg: File - Create ("GFG - TXT")
2 pages
Python Revision Tour-2 Worksheet
PDF
No ratings yet
Python Revision Tour-2 Worksheet
8 pages
Ge8151 Phython Prog Unit 4 New
PDF
No ratings yet
Ge8151 Phython Prog Unit 4 New
33 pages
Car Details From Car Dekho
PDF
No ratings yet
Car Details From Car Dekho
212 pages
Python Main Program Set 2
PDF
No ratings yet
Python Main Program Set 2
18 pages
Data Visualization PDF
PDF
No ratings yet
Data Visualization PDF
3 pages
Dictionaries in Python
PDF
No ratings yet
Dictionaries in Python
21 pages
Xi CS Worksheet List Tuples
PDF
No ratings yet
Xi CS Worksheet List Tuples
4 pages
Vision International School of Excellence Class: 11 CHAPTER-: List Manipulation
PDF
No ratings yet
Vision International School of Excellence Class: 11 CHAPTER-: List Manipulation
2 pages
International Indian School, Riyadh WORKSHEET (2020-2021) Grade - Xii - Informatics Practices - Second Term
PDF
No ratings yet
International Indian School, Riyadh WORKSHEET (2020-2021) Grade - Xii - Informatics Practices - Second Term
9 pages
Statistics Assignemt
PDF
100% (1)
Statistics Assignemt
19 pages
Python Numpy (1) : Intro To Multi-Dimensional Array & Numerical Linear Algebra
PDF
100% (1)
Python Numpy (1) : Intro To Multi-Dimensional Array & Numerical Linear Algebra
27 pages
MCQ Questions
PDF
No ratings yet
MCQ Questions
8 pages
C Programming Question Bank
PDF
No ratings yet
C Programming Question Bank
3 pages
Zivame Planning Analyst Excel SQL Test
PDF
No ratings yet
Zivame Planning Analyst Excel SQL Test
50 pages
Pandas Questions
PDF
No ratings yet
Pandas Questions
4 pages
List of Practicals of XII Computer Science 083 Practical Files 2022 23
PDF
No ratings yet
List of Practicals of XII Computer Science 083 Practical Files 2022 23
5 pages
Python Date Time
PDF
No ratings yet
Python Date Time
6 pages
EDA Assignment
PDF
No ratings yet
EDA Assignment
16 pages
Untitled Spreadsheet
PDF
No ratings yet
Untitled Spreadsheet
3 pages
New - SQL Qustions
PDF
No ratings yet
New - SQL Qustions
3 pages
Python Practice Problems List
PDF
No ratings yet
Python Practice Problems List
4 pages
Linear Reg 1
PDF
No ratings yet
Linear Reg 1
7 pages
Chapter 4 File Handlinf Final (New)
PDF
100% (1)
Chapter 4 File Handlinf Final (New)
78 pages