ProblemSet11_23f - Jupyter Notebook
.pdf
keyboard_arrow_up
School
Washtenaw Community College *
*We aren’t endorsed by this school
Course
141
Subject
Computer Science
Date
Dec 6, 2023
Type
Pages
6
Uploaded by DeanPelican3624
12/3/23, 1:45 PM
ProblemSet11_23f - Jupyter Notebook
https://zeus-clone.wccnet.edu/user/e28785829b1e407584d9d2477cd58899/notebooks/ProblemSet11_23f.ipynb#
1/6
Problem Set 11
Overiew
This learning unit's focus is on the use of the built-in
map()
(https://www.w3schools.com/python/ref_func_map.asp)
,
filter()
(https://www.w3schools.com/python/ref_func_filter.asp)
,
zip()
(https://www.w3schools.com/python/ref_func_zip.asp)
functions, as well as
list
comprehension
(https://www.w3schools.com/python/python_lists_comprehension.asp)
.
Solve the problems below using these tools as indicated in the instructions.
Run the code cell below
The objects that are created in the cell below will be used throughout the problem set. Do not
overwrite these objects, and do not duplicate this code in your solutions.
In [ ]:
Problem 1
Retrieve the
computeScrabbleScore()
function developed in previous problem sets (PS 5, 6,
7), or re-write it here. This function accepts a string as a parameter and returns an integer that
represents the Scrabble score for the string. The
letter_values
dictionary is provided below.
Outside of the function, use the
map()
function to make a list of Scrabble scores for each
respective item in the
words
list.
Print the list of scores.
In [ ]:
In [ ]:
Expected Output:
[14, 12, 4, 7, 11, 8, 16, 5]
<enter your name here>
myInts
=
[ i
for
i
in
range
(
1
,
301
) ]
words
=
[
'python'
,
'program'
,
'list'
,
'string'
,
'unix'
,
'hours'
,
'syntax'
,
myQuote
=
"The quality of mercy is not strained it dropeth as the gentle r
letter_values
=
{
'a'
:
1
,
'b'
:
3
,
'c'
:
3
,
'd'
:
2
,
'e'
:
1
,
'f'
:
4
,
'g'
:
2
,
'h'
:
4
,
'i'
:
1
,
'j'
:
8
,
'k'
:
5
,
'l'
:
1
,
'm'
:
3
,
'n'
:
1
,
'o'
:
1
,
'p'
:
3
,
'q'
:
10
,
'r'
:
1
,
's'
:
1
,
't'
:
1
,
'u'
:
1
,
'v'
:
8
,
'w'
:
4
,
'x'
:
8
,
'y'
:
4
,
'z'
:
10
}
# write your solution below
1
1
2
3
1
2
3
1
2
12/3/23, 1:45 PM
ProblemSet11_23f - Jupyter Notebook
https://zeus-clone.wccnet.edu/user/e28785829b1e407584d9d2477cd58899/notebooks/ProblemSet11_23f.ipynb#
2/6
Problem 2
Using the
words
list and the
selectWord()
function (described below), produce a list named
evenWords
that contains only those items from
words
that have an even number of
characters.
Write
selectWord()
such that it accepts the parameter
word
, which is a string. The function
will return
True
if the length of the string is an even number. Otherwise it will return
False
.
Outside of the function use
filter()
along with
selectWord()
to create and print
evenWords
.
In [ ]:
Expected Output:
['python', 'list', 'string', 'unix', 'syntax']
Problem 3
Alter your solution for Problem 2 to use only a
list comprehension
(instead of the
filter()
function) to create a list of words with an
odd
number of letters. You are free to re-
use the
selectWord()
function from Problem 2, but do not re-write it here.
In [ ]:
Expected Output:
['program', 'hours', 'error']
Problem 4
Use a list comprehension to create a reverse-ordered list of tuples based on the
myQuote
string. The tuples will hold each word from
myQuote
, along with it's Scrabble score. The built-in
reversed()
function will be useful here.
In [ ]:
Expected Output:
# write your code below
# write your code here
# write your code below
1
2
1
2
1
2
12/3/23, 1:45 PM
ProblemSet11_23f - Jupyter Notebook
https://zeus-clone.wccnet.edu/user/e28785829b1e407584d9d2477cd58899/notebooks/ProblemSet11_23f.ipynb#
3/6
[('heaven', 16), ('from', 9), ('rain', 4), ('gentle', 7), ('the', 6),
('as', 2), ('dropeth', 13), ('it', 2), ('strained', 9), ('not', 3),
Problem 5
The variable
names
is a list where each item is a string in "Firstname Lastname" format.
Make a list named
newNames
from
names
where each item is in "Lastname, Firstname"
format. Use list comprehension to convert the list.
In [ ]:
In [ ]:
Expected Output:
['Newton, Isaac', 'Einstein, Albert', 'Bohr, Niels', 'Curie, Marie',
'Darwin, Charles', 'Galilei, Galileo', 'Mead, Margaret']
Problem 6
Use list comprehension to create a list of those numbers from
myInts
that are evenly divisible
by 17
but are not
evenly divisible by 51.
Use only three lines of code: the first will create the list; the second will print the list; the third will
print the length of the list.
In [ ]:
Expected Output:
[17, 34, 68, 85, 119, 136, 170, 187, 221, 238, 272, 289]
list length: 12
Problem 7
Use list comprehension to create a list of numbers from
myInts
that contain 99 or 44.
Use only three lines of code: the first will create the list; the second will print the list; the third will
print the length of the list.
names
=
[
"Isaac Newton"
,
"Albert Einstein"
,
"Niels Bohr"
,
"Marie Curie"
,
"Charles Darwin"
,
"Galileo Galilei"
,
"Margaret Mead"
]
# write your code below
# write your code below
1
2
1
2
1
2
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
O RottenAnchoredDecagons x
M (no subject) - jcofield122e x
O Lab 6: Module 6 - Repetitis x
https://tcc.instructure.com/courses/42392/assignments/976548?module_item_id32464159
-Write a program with af
as Program for Fibonacci nu x i1390rmc01171ipg (1920 x0 1390
Write a program with a for loop that displays the numbers 1 to 10 and their respective cubes. You may want to use the range function. Your output should look like the example
Number
Cube
******
1
8
27
4
64
125
5.
216
343
512
8.
729
9.
1000
10
To format your table you can use the tab syntax, \t, to tab your output. For example:
print("Number\t Square")
arrow_forward
Develop a data type for a buffer in a text editor that implements the following API:public class BufferBuffer() create an empty buffervoid insert(char c) insert c at the cursor positionchar delete() delete and return the character at the cursorvoid left(int k) move the cursor k positions to the leftvoid right(int k) move the cursor k positions to the rightint size() number of characters in the bufferAPI for a text bufferHint : Use two stacks
arrow_forward
Can someone help about my assignment?
Instruction is on image:
Given:
Last Name First Name ID Phone Salary=========== ========== ======== ======= =====Wood Carpenter 333556666 222-222-2222 40000Ironman Iron 444444443 828-888-8888 73000Goal-keeper Martin 777777777 888-666-8888 86000
Here is the input file.Doe John 555555555 333-333-3333 65000Doe Jan 444444444 333-333-3333 75000Hardworker John 888888888 888-888-8888 55000Programmer Travis 555446666 666-666-6666 76000
Output:Original ListLast Name First Name ID Phone Salary=========== ========== ======== ======= =====Doe John 555555555 333-333-3333 85000Doe…
arrow_forward
After you have read the required chapters from the text for this unit, visit and read the following website to learn more about Gestalt Psychology.http://en.wikipedia.org/wiki/Gestalt_psychology
Now, consider at least one interface that you use at least several times a week. Think outside of the box - this doesn't have to be your computer - in fact, I would prefer it NOT be - it can be your phone, your television, or some other electronic interface. Describe concisely (no fluff, please!) how at least TWO of the "Laws of Grouping" were applied to the design of the interface that you chose.
arrow_forward
Blue-Eyed Island: A bunch of people are living on an island, when a visitor comes with a strangeorder: all blue-eyed people must leave the island as soon as possible. There will be a flight out at8:00pm every evening. Each person can see everyone else's eye color, but they do not know theirown (nor is anyone allowed to tell them). Additionally, they do not know how many people haveblue eyes, although they do know that at least one person does. How many days will it take theblue-eyed people to leave?
arrow_forward
Taken from chegg, please provide orginal non plagarised work.
https://www.chegg.com/homework-help/questions-and-answers/hi-m-struggling-please-provide-pswedocode-java-comment-thanks-q72540970
arrow_forward
Computer Science
Assume you are a software developer that has written a system that analyses pictures of various recyclable items (such as a can, bottle or a crate). It can be used via a Web Application (Web API), i.e., the users send pictures over the Internet. The system returns for each picture how many of each item are seen in the picture. Discuss if this service should be offered for free. Justify your answer
arrow_forward
Hello I'm not sure why my results are repeating. Did I code wrong?
arrow_forward
Please help me with this Operating systems principles homework project (NOT GRADED)
CHECK ATTACHED IMAGES FOR PROJECT SPECS
Job Object Class
ATTRIBUTES (Make “friendly” / “protected”)
-arrTime -random 1-250
-cpuBurst -random 2-15
-priority -random 1-5 (5 is highest)
-exitTime -algorithm result
-turnAroundTime -algorithmresult
-remainingTime -updated in algorithms
METHODS:
-constructor(s)
-toString (to display initial jobs and algorithm results)
-compareTo (general, by arrival time)
//Note: different algorithms may need a different compare. i.e. by priority, etc.
Those can be defines in the algorithm methods.
arrow_forward
putty program for unix
arrow_forward
Abstract: the main purpose of this experiment is build real time system using PPI
8255 to control devices connected to.
Problem description: assume that there are two devices are connected to port A and
two sensors are connected to port B of PPI 8255. They work according to the
following table
Sensors (S1S2)
Devices (DID2)
00
01
01
10
10
11
11
00
Write a program to control these two devices according to the values of sensors.
arrow_forward
Draw an er-daigram for a game (Android application)
with four users in it
1- The admin updates the game, deletes, edits and
creates
2- Parents see and evaluate the results of their
children
3- The teacher sees and evaluates the results of his
students
4- The child plays
arrow_forward
COMPUTER SCIENCE NEED A EDUCATED PERSON TO HELP WITH GENDERMAG
arrow_forward
Image classification from scratch
- transfer learning
- medical image classification
Choose one task, the write code and run it on your PC for your task. and then try to improve the performance.
arrow_forward
6.
#
arrow_forward
Please watch the Ted Talks Video
"Machine intelligence makes human morals more important"
https://www.ted.com/talks/zeynep_tufekci machine intelligence makes human morals more important?referrer=p
laylist-the inherent bias in our techn
"Artificial Intelligence does not give us a "Get out of ethics free" card.
Software is becoming more powerful, but it's also less transparent and more complex. We're asking questions to
computation that have no single right answers, that are subjective and open-ended and value-laden."
The video describes problems caused by these "black box algorithms" in hiring, parole & sentencing
guidelines, etc. Describe at least TWO of these and your reaction to those problems.
These systems are trained on data generated by our actions -- why can this cause problems? Provide at
least TWO specific examples mentioned in the video.
These systems can also be wrong in ways that don't resemble human systems. Describe 2 of the
incidents mentioned in the video and your…
arrow_forward
The Tower of Hanoi Problem Tower of Hanoi is a mathematical game consisting of three pegs (P1, P2 and P3) and a stack of disks of different diameters. Disks can slide onto any peg. The game starts with all disks stacked on P1 and ends at the point where all disks stacked on P3. The game player is required to move all disks from P1 to P3 using P2 as a buffer. Three rules must be followed when playing the game (1) Only one disk may be moved at a time. (2) Each move involves taking a disk on the top of a peg and place it on the top of another peg. (3) A disk of a larger diameter should never be placed on top of a disk of a smaller diameter. The diagrams below demonstrate the starting state and goal state of the game with 5 disks. starting sate p1 to goal state p3 Requirements In this assignment, students are required to solve the Tower of Hanoi (with five disks) using state space search algorithms implemented in Python. Two state space search algorithms: (1) a blind search (depth-first…
arrow_forward
Fgjddgnbfjvxgh
arrow_forward
please give implementation of
unsigned int getL1SetID(u_int32_t address){///// IMPLEMENT THIS /////return 0;}unsigned int getL2SetID(u_int32_t address){///// IMPLEMENT THIS /////return 0;}unsigned int getL1Tag(u_int32_t address){///// IMPLEMENT THIS /////return 0;}unsigned int getL2Tag(u_int32_t address){///// IMPLEMENT THIS /////return 0;}
arrow_forward
Abstract: the main purpose of this experiment is build real time system using PPI
8255 to control devices connected to.
Problem description: assume that there are two devices are connected to port A and
two sensors are connected to port B of PPI 8255. They work according to the
following table
Devices (DID2)
01
10
Sensors (S1S2)
00
01
10
11
11
00
Write a program to control these two devices according to the values of sensors.
Each group should submit a zip file which contains the following files
Code file: (assembly language code)
- Simulation file
Report (pdf file) (details of every single step in the code, also what have you
learned from this experiment)
arrow_forward
7
arrow_forward
A bunch of people are living on an island, when a visitor comes with a strangeorder: all blue-eyed people must leave the island as soon as possible. There will be a flight out at8:00pm every evening. Each person can see everyone else's eye color, but they do not know theirown (nor is anyone allowed to tell them). Additionally, they do not know how many people haveblue eyes, although they do know that at least one person does. How many days will it take theblue-eyed people to leave?
arrow_forward
This is the link to the book: (the pages to the figs 10.4 -10.9 are 1159 - 1176)
https://ipfs.io/ipfs/bafykbzaceazxlwbrjmdk7ytxkp72zt4htqvcwotwpmiulqvniyzonm7w76uwq?filename=Paul%20Deitel%2C%20Harvey%20Deitel%20-%20Java_%20How%20to%20Program%20Early%20Objects-Pearson%20%282017%29.pdf
arrow_forward
Please help me with this Operating systems principles homework project (NOT GRADED)
Job Object Class
ATTRIBUTES (Make “friendly” / “protected”)
-arrTime -random 1-250
-cpuBurst -random 2-15
-priority -random 1-5 (5 is highest)
-exitTime -algorithm result
-turnAroundTime -algorithmresult
-remainingTime -updated in algorithms
METHODS:
-constructor(s)
-toString (to display initial jobs and algorithm results)
-compareTo (general, by arrival time)
//Note: different algorithms may need a different compare. i.e. by priority, etc.
Those can be defines in the algorithm methods.
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Related Questions
- O RottenAnchoredDecagons x M (no subject) - jcofield122e x O Lab 6: Module 6 - Repetitis x https://tcc.instructure.com/courses/42392/assignments/976548?module_item_id32464159 -Write a program with af as Program for Fibonacci nu x i1390rmc01171ipg (1920 x0 1390 Write a program with a for loop that displays the numbers 1 to 10 and their respective cubes. You may want to use the range function. Your output should look like the example Number Cube ****** 1 8 27 4 64 125 5. 216 343 512 8. 729 9. 1000 10 To format your table you can use the tab syntax, \t, to tab your output. For example: print("Number\t Square")arrow_forwardDevelop a data type for a buffer in a text editor that implements the following API:public class BufferBuffer() create an empty buffervoid insert(char c) insert c at the cursor positionchar delete() delete and return the character at the cursorvoid left(int k) move the cursor k positions to the leftvoid right(int k) move the cursor k positions to the rightint size() number of characters in the bufferAPI for a text bufferHint : Use two stacksarrow_forwardCan someone help about my assignment? Instruction is on image: Given: Last Name First Name ID Phone Salary=========== ========== ======== ======= =====Wood Carpenter 333556666 222-222-2222 40000Ironman Iron 444444443 828-888-8888 73000Goal-keeper Martin 777777777 888-666-8888 86000 Here is the input file.Doe John 555555555 333-333-3333 65000Doe Jan 444444444 333-333-3333 75000Hardworker John 888888888 888-888-8888 55000Programmer Travis 555446666 666-666-6666 76000 Output:Original ListLast Name First Name ID Phone Salary=========== ========== ======== ======= =====Doe John 555555555 333-333-3333 85000Doe…arrow_forward
- After you have read the required chapters from the text for this unit, visit and read the following website to learn more about Gestalt Psychology.http://en.wikipedia.org/wiki/Gestalt_psychology Now, consider at least one interface that you use at least several times a week. Think outside of the box - this doesn't have to be your computer - in fact, I would prefer it NOT be - it can be your phone, your television, or some other electronic interface. Describe concisely (no fluff, please!) how at least TWO of the "Laws of Grouping" were applied to the design of the interface that you chose.arrow_forwardBlue-Eyed Island: A bunch of people are living on an island, when a visitor comes with a strangeorder: all blue-eyed people must leave the island as soon as possible. There will be a flight out at8:00pm every evening. Each person can see everyone else's eye color, but they do not know theirown (nor is anyone allowed to tell them). Additionally, they do not know how many people haveblue eyes, although they do know that at least one person does. How many days will it take theblue-eyed people to leave?arrow_forwardTaken from chegg, please provide orginal non plagarised work. https://www.chegg.com/homework-help/questions-and-answers/hi-m-struggling-please-provide-pswedocode-java-comment-thanks-q72540970arrow_forward
- Computer Science Assume you are a software developer that has written a system that analyses pictures of various recyclable items (such as a can, bottle or a crate). It can be used via a Web Application (Web API), i.e., the users send pictures over the Internet. The system returns for each picture how many of each item are seen in the picture. Discuss if this service should be offered for free. Justify your answerarrow_forwardHello I'm not sure why my results are repeating. Did I code wrong?arrow_forwardPlease help me with this Operating systems principles homework project (NOT GRADED) CHECK ATTACHED IMAGES FOR PROJECT SPECS Job Object Class ATTRIBUTES (Make “friendly” / “protected”) -arrTime -random 1-250 -cpuBurst -random 2-15 -priority -random 1-5 (5 is highest) -exitTime -algorithm result -turnAroundTime -algorithmresult -remainingTime -updated in algorithms METHODS: -constructor(s) -toString (to display initial jobs and algorithm results) -compareTo (general, by arrival time) //Note: different algorithms may need a different compare. i.e. by priority, etc. Those can be defines in the algorithm methods.arrow_forward
- putty program for unixarrow_forwardAbstract: the main purpose of this experiment is build real time system using PPI 8255 to control devices connected to. Problem description: assume that there are two devices are connected to port A and two sensors are connected to port B of PPI 8255. They work according to the following table Sensors (S1S2) Devices (DID2) 00 01 01 10 10 11 11 00 Write a program to control these two devices according to the values of sensors.arrow_forwardDraw an er-daigram for a game (Android application) with four users in it 1- The admin updates the game, deletes, edits and creates 2- Parents see and evaluate the results of their children 3- The teacher sees and evaluates the results of his students 4- The child playsarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education