All Matches
Solution Library
Expert Answer
Textbooks
Search Textbook questions, tutors and Books
Oops, something went wrong!
Change your search query and then try again
Toggle navigation
FREE Trial
S
Books
FREE
Tutors
Study Help
Expert Questions
Accounting
General Management
Mathematics
Finance
Organizational Behaviour
Law
Physics
Operating System
Management Leadership
Sociology
Programming
Marketing
Database
Computer Network
Economics
Textbooks Solutions
Accounting
Managerial Accounting
Management Leadership
Cost Accounting
Statistics
Business Law
Corporate Finance
Finance
Economics
Auditing
Ask a Question
Search
Search
Sign In
Register
study help
computer science
introduction to computing and programming in pytho
Questions and Answers of
Introduction to Computing and Programming in Pytho
Write a function to make lighter the left side of a picture, and turn the right side into a grayscale.
Write a function that decreases red by 50% on the left side of the picture, and increases it by 200% on the right side.
Write a function that pinkifies white in a picture. Input a picture, then check each pixel to see if the red, green, and blue are all over 100. If so, set that pixel to pink.
Write a function that posterizes an input picture along a very specific process. If the red value is greater than 180, then set the pixel to red. If not, then check if the blue value is greater than
Write a function to put 10 pixel wide “prison cell bars” on the left border, center, and right border of an input picture.
The process we used to draw borders could actually be used to draw lines as well. For example, if you have a square picture, every pixel whose x value equals its y value lies on the diagonal from
Write a function that inputs a picture, a color, and a number. The number is the width of a border that you are to draw on all four sides of the picture, with the given color. You can assume that the
Imagine that you have a picture, and you are painting a copy of it. But you have only eight colors. Write a function that inputs a picture, and makes these changes to each pixel. For each of red,
Write a function called changeColor that takes as input a picture and an amount to increase or decrease a color by and a number 1 (for red), 2 (for green), or 3 (for blue). The amount will be a
The function mirrorHalf mirrors the top half of the picture onto the bottom half. Write a newfunction mirrorUpHalf that mirrors the top half of the picture into the top.
The function copyHalf copied the top half of the picture into the bottom half. Write a new function copyUpHalf that copies the bottom half of the picture into the top.
Write a function that takes a picture as input, and make the top half of the picture black.
Rewrite the clear blue program (Program 36 (page 94)) to maximize blue (i.e., set it to 255) instead of clearing it. Is this useful?Would the red or green versions of the maximize function be useful?
Write three functions, one to clear blue (Program 36 (page 94)) and one to clear red, and one to clear green. For each of these, which would be the most useful in actual practice? How about
What does the following function do? def test3 (picture): for p in getPixels(picture): setGreen (p,0)
What does the following function do? def test4 (picture): for p in getPixels(picture): getRed (p) + 10 getGreen (p) + 10 blue = getBlue (p) + 10 red green = color makeColor(red, green, blue)
What does the following function do? def test5 (picture): for p in getPixels (picture): getRed (p) - 20 getGreen (p) - 20 blue = getBlue (p) - 20 red green color makeColor(red,green,blue)
What does the following function do? def test6 (picture): for p in getPixels(picture): red = getRed (p) getGreen (p) getBlue (p) makeColor (blue, red, green) green blue = color setColor(p, color)
What does the following function do? def test7 (picture): for p in getPixels (picture): getRed (p)/2 getGreen (p)/2 blue = getBlue (p)/2 red green = color = makeColor(red, green, blue) setColor(p,
What does the following function do? By reading the program without running it, do you think that the result of test8 will be lighter or darker than the result of test7? def test8 (picture): for p in
Write a function to “blue-ify” a face. Write a function that accepts a picture as input. If any pixel has a blue value less than 150, then set that pixel’s color to white. Try it on a picture
Write a general “blue-ify” function. Write a function that accepts a picture as input, then doubles the blue value of every pixel and cut the red and green values in half.
Write a general “red-ify” function. Write a function that accepts a picture as input, then doubles the red value of every pixel and cut the blue and green values in half.
Write a function to change a picture to grayscale and then negate it.
Write a function to create a lightened grayscale image. First, lighten the image by adding 75 to the red, green, and blue components of every pixel. Since higher numbers are closer to white, this
Write a function to create a lightened grayscale image, by use makeLighter. First, lighten the image by using the makeLighter function on each color. Now, grayscale the new image. Compare the result
What does the following function do? def test2 (picture): for p in getPixels(picture): setBlue (p, getBlue(p) * 1.5)
What does the following function do? def testl (picture): for p in getPixels (picture): setRed (p, getRed (p) * 0.3)
Write a function to set the red, green, and blue values to 255. What is the result?
Write a function to set the red, green, and blue values to zero. What is the result?
Write a function to swap the values of two colors, for example, swap the red value with the blue value.
If you keep increasing the red value and wrapping is on, eventually some pixels become bright green and blue. If you check those pixels with the picture tool, you’ll find that the values of red are
Each of the following is equivalent to the increase red function—Program 35 (page 94). Test them and convince yourself that they work. Which do you prefer and why?Data from Problem 35Increase the
Write the blue and green versions of the reduce red function—Program 34.Data from Problem 34Reduce the Amount of Red in a Picture by 50% def decreaseRed (picture): for pix in getPixels(picture):
Program 34 (page 89) obviously reduces the red by too much. Write a version that only reduces the red by 10%, then one by 20%. Can you find pictures where each is most useful? Note that you can
Picture concept questions:• Why don’t we see red, green, and blue spots at each position in our picture?• What is hierarchical decomposition? What is it good for?• What is luminance?• Why
Same problem as before, but you decide to use more of your new Python skills. You are going to increase the spaces between the words. Write a function that takes a string and a number of spaces to
You have written an essay for school, and it has to be at least five pages long. But your essay is only 4.5 pages long!You decide to use your new Python skills to make your essay longer by spacing
One of the below programs that when called like this (with the underscore representing a digit from 1 to 4) generates this output:>>> findem_(4)'abcdabcdabcdabcdabcdabcda'Which one?
The buildCipher function could create more complicated alphabets. As long as both the receiver and the sender generate the alphabet in the same way, the message needs to only include the keyword for
Change the encode function so that punctuation is simply skipped.
Change the encode function so that spaces are simply skipped.
Write a program that accepts a string as input, then prints out the vowels in that string and then prints the consonants in that string.>>> splitem("elephant")Vowels: eeaConsonants: lphnt
Try giving our doubledutch program a full name like “John Smith.” What happens to the space? What if you include punctuation like periods or hyphens? How could you create more full
One of the below programs that when called like this (with the underscore representing a digit from 1 to 4) generates this output:>>> dup_("rubber duck")’kcud rebburrubber duck’Which
We fixed justvowels so that it works with lowercase or uppercase vowels. Fix notvowels so that it doesn’t print out uppercase vowels. (Try it as it is in the chapter, and you will see that it does
Using for loops and using the same techniques as the pyramid function, create a textsquare function that takes in two values as input: the character to use in making the square, and the size of the
Create a function like the pyramid function that does the upside-down version. Your function invertedPyramid should also take an input character and print an inverted pyramid.
The pyramid function in this chapter doesn’t quite line up with “=” character as input. Try some others, like "n" and "m" and "t". The last one seems to line up best. Why?
You are a race official on an ultra marathon (100 miles), and you want to display the number and elapsed time for each runner on a big display. Write a program to generate the phrase for the display
You are running a bingo game where you want to tweet the winner of each round of the game.You want to announce the name of who won, and how much they won in dollars. Make a function that takes those
Try running the code below. What is the result? Why did you get that?>>> print abs(-5)5>>> myfunc = abs>>> print myfunc(-5)
We evaluated the expression pickAFile() when we wanted to execute the function named pickAFile. But what is the name pickAFile anyway? What do you get if you print pickAFile? How about
Try some other operations with strings in JES. What happens if you multiply a number by a string, like 3 * "Hello"? What happens if you try to multiply a string by a string, "a" * "b"?
The following code gives the error message shown below. Fix the code.>>> a = 3>>> b = 4>>> c = d * aThe error was:dName not found globally.A local or global name could not
The following code gives the error message shown below. Fix the code.>>> pickafile()The error was:pickafileName not found globally.A local or global name could not be found. You needto
Type the function below into the Program Area of JES, then load the program and type into the Command Area compute(). What is being computed by the following?def compute3():heightInStories =
Type the function below into the Program Area of JES, then load the program and type into the Command Area compute(). What is being computed by the following?def compute2():gravity =
Type the function below into the Program Area of JES, then load the program and type into the Command Area compute(). What is being computed by the following?def compute():distanceInMiles =
What is the output from the following?>>> first = "Abe">>> last = "Lincoln">>> swap = first>>> first = last>>> last = swap>>> print first + " " +
What is the output from the following?>>> first = "Abe">>> last = "Lincoln">>> print first + " " + last
What is the output from the following?>>> first = "Abe">>> last = "Lincoln">>> print first + last
What is the output from the following?>>> name = "Barb">>> name = "Mark">>> print name
What is the output from the following?>>> a = -4>>> b = 2>>> c = abs(a)>>> x = a * c>>> print x
What is the output from the following?>>> a = 4>>> b = 2>>> x = b - a>>> print x
What is the output from the following?>>> a = 4>>> b = 2>>> x = a / b>>> print x
What is the output from the following?>>> a = 3>>> b = -5>>> a = b>>> b = 22>>> x = a * b>>> print x
What is the output from the following?>>> a = 3>>> b = -5>>> x = a * b>>> print x
What is the output from the following?>>> a = 3>>> b = 4>>> x = a * b>>> print x
What does show(p) do?
What is the output from print "Hi" + "10"? Why do you get this output?
What is the output from print "Hi" * "10"? Why do you get this output?
What is the output from print "Hi" + "there"?Why do you get this output?
What is the output from print "Hi" * 10? Why do you get this output?
What is the output from print "Hi" + 10? Why do you get this output?
What is the output from print "Hi" + "there"?Why do you get this output?
What is the output from print (10 + 3) * 7? Why do you get this output?
What is the output from print 10 + 3 * 7? Why do you get this output?
What is the output from print 1.0 / 3? Why do you get this output?
What is the output from print 1 / 3? Why do you get this output?
What does print mean? What does the statement print a do?
What does def mean? What does the statement def someFunction(x,y): do?
Computer science representation (encoding) questions:• How can computers represent pictures as numbers?• How can computers represent text as numbers?• Remember that the computer can only
Computer science concept questions:• What is an algorithm?• What is an encoding?• What is the difference between an algorithm and a program?
Now trace this series of who built on who’s work.• Who invented the laser printer?• One of the winners of the ACM Turing Award (the closest that computer science has to a Nobel Prize) invented
Look up Ashley Qualls on theWeb. What did she create that is worth a million dollars?
Look up Mary Lou Jepsen on the Web. What new technology is she working on?
Look up Shafi Goldwasser on the Web. What major computing prize did she win in 2012 and why?
As in every field, people in computer science build on one another’s work.• Who invented the Logo Turtle?• Who used the Logo Turtle to have fourth graders learn about fractions in
Look up Tim Berners-Lee on theWeb. What did he invent?
Look up Marissa Mayer on the Web. What computer tool (that you probably use regularly) did she help create?
Look up Richard Tapia on theWeb. What has he done to encourage diversity in computing?
Look up Claude Shannon on theWeb. What did he do for his master’s thesis?
Look up Ada Lovelace on theWeb. What amazing things did she do before the first mechanical computer was built?
Look up Kurt G¨odel on the Web. What amazing things did he do with encodings?
Look up Adele Goldberg on theWeb. How did she contribute to programming languages?
Look up Alan Turing on the Web. What does he have to do with our notion of what a computer can do and how encodings work?
Look up Andrea Lawrence on theWeb. What computer science department did she chair?
Look up Grace Hopper on the Web. How did she contribute to programming languages?
Look up Clarence (Skip) Ellis. Without him, Google Docs wouldn’t work the way that it does to help people collaborate. What did he do?
Showing 300 - 400
of 410
1
2
3
4
5