Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In python. (beginner) et is an unordered collection of data types that is iterable, utable, and has no duplicate elements. The order of ements in
In python. (beginner)
et is an unordered collection of data types that is iterable, utable, and has no duplicate elements. The order of ements in a set is undefined though it may consist of arious elements. isplay each of the following results a) Create an empty set (blank set) b) Create a set from a given string "COMP2150 python" c) Create a set from the following list: Lst = ["North", "East", "South" ,"West","East", "East"] d) Create a Set with a mixed type of values (Having numbers and strings) [1, 2, 'North', 4, 'East', 6, 'South',33,77] Result: a. Initial blank Set: set() b. Set from a given String: "COMP2150 python" \{'5', 'o', 't', '1', 'C', 'n', 'h', 'O', '2', 'p', 'P', '', 'M', 'y', '0'\} c. Set from a given List: ["North", "East", "South" ,"West","East", "East"] " \{'North', 'South', 'East', 'West'\} d. Set from a given mixed Values: [1, 2, 'North', 4, 'East', 6, 'South',33,77, 33.1] \{'North', 1, 2, 33, 4, 'East', 6, 33.1, 77, 'South'\} onary \{\} is a "powerful" built-in data structure in of "performance". We will discuss that later in the tructure lecture(s). Similar to the list[ ], there are ole ways of creating a dictionary data structure. lict\{ key, value\} Nithin a directory (dict(..),keyscannothave luplicates, but duplicate values (any datatype) are llowed. Python has a built-in dict() method to create a lictionary data type this exercise: create a dictionary data type (d1) a) Create an empty dictionary data type b) Create a dictionary with Integer Keys eg: \{ 1: "COMP', 2: '2150', 3:' python' c) Create a dictionary with mixed keys \{'name': 'COMP'. 1:[1,2,3,4] d) Create a dictionary using the build-in dictO method \{1: 'COMP', 2: '2150', 3: 'python'\} e) Create a dictionary with each item paired. (using dict()) i. [(1, 'COMP'), (2, '2150'), (3, 'python' )] Results: a. Empty Dictionary: \{\} b. Dictionary with the use of Integer Keys: \{1: 'COMP', 2: '2150', 3: 'python'\} c. Dictionary with Mixed Keys: \{'Hello': 'COMP', 1: [2, 1,5,0]\} d. Dictionary using the dict(O: function \{1: 'COMP', 2: '2150', 3: 'python'\} e. Dictionary with each item as a pair: \{1: 'COMP', 2: '2150', 3: 'python'\} Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started