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
Hire a Tutor
AI Study Help
New
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
Create a movie with boxes growing and shrinking in it.
Finish the Joe the Box example.(a) Implement grow and move. The method move takes as input a relative distance like (−10,15) to move 10 pixels left (x position) and 15 pixels down (y position).(b)
Create a movie with several turtles moving in each frame, like our dance function. Move each turtle, pause, and save it to a frame.
Add a method to the Turtle class to draw a letter.
Add a method to the Turtle class to draw a street of houses.
Add a method to the Turtle class to draw a simple house. It can have a rectangle for the house and an equilateral triangle as the roof.
Make some modifications to Joe the Box.• Add a method to Box named setColor that takes a color as input, then makes the input color the newcolor for the box. (Maybe setDefaultColor should call
Rewrite the mirror functions as methods in the MyPicture class.
Use the methods in the Picture class to draw a rainbow.
Use the methods in the Picture class to draw a smiling face.
Create a PlayList class that takes a list of sounds and play them one at a time.
Add a field to the SlideShow class to hold the title and modify the show method to first show a blank picture with the title on it.
Create a Student class. Each student should have a name and a picture. Add a method, show, that shows the picture for the student.
Create a CartoonPanel class that takes an array of Pictures and displays the pictures from left to right. It should also have a title and author, and display the title at the top left edge and the
Create a SlideShow class that holds a list of slides and shows each slide one at a time.
Add another constructor to the Slide class that takes just a picture filename and plays no sound when it plays.
Add a method to the Turtle class to draw your initials.
Add a method to the Turtle class to draw a rectangle given a width and height.
Add a method to the Turtle class to draw an equilateral triangle.
Answer the following questions about how objects work, using this chapter and explorations on theWeb.• What is inheritance?• What is a superclass?• What is a subclass?• What methods does a
Answer the following questions about object-oriented programming, using this chapter and explorations on the Web.• What is the difference between an instance and a class?• How are functions and
The techniques we used to create recursive triangles can be used with other figures as well. Create nested and corner versions of squares and of pentagons.
Now, use blocking Play on different sounds to get music to go with the dance.
We can get the same effect as sleep by playing a sound with blocking Play. Change the dance code to use a brief sound to pause the dance, rather than sleep.
We can make all motions of a turtle slower by using a form of forward that includes sleepdef pausedForward(turtle,amount): sleep(0.2) turtle.forward(amount)Rewrite the chase and dance
Look up Koch’s snowflake. Write a recursive function with turtles to create Koch’s snowflake.
Look up Sierpinski’s triangle. Write a recursive function with turtles to create Sierpinski’s triangle.
Try to write upDown() both recursively and without recursion.Which is easier? Why?Try writing upDown(): >>> upDown("Hello") Hello Hell Hel He H
Write a recursive method to list all the files in a directory and in all subdirectories.
http://abcnews.go.com is a popular news site. Let’s make a movie of it. Write a function that will input a directory as a string. Then:• Visit http://abcnews.go.com and pick out the top three
The Guardian’s Web site includes CSV data on how often the groundhog correctly predicts Spring on Groundhog Day. Write a program to grab thatCSV file and add up the number of corrects and the
What is an ISP? Can you give an example of one?
Add the ability for the player to lose the game (perhaps die). When the player loses, the game should print what happened, and then the game exits. Perhaps finding the Ogre without the bomb in the
Write a function to input a sound, then create a canvas sound of the same length. Copy samples from the input into the canvas every other position, i.e., copy from index 0 in the input into the
Write a new version of Program 104 to use index array notation (with square brackets).Data from Program 104 #Stick some quiet space after that for index in range (0,1000): setSampleValueAt(target,
Write a new version of Program 104 to copy “We the” into a new sound and then copy in “united” and finally copy in “people.” Be sure to add 2250 samples with a value of 0 in between the
Write a general scaleUp function that takes in any picture and creates and returns a new picture twice as big using makeEmptyPicture(width,height).
Write a general crop function that takes a source picture, the start X value, the start Y value, the end X value, and the end Y value. Create and return the new picture and copy just the specified
It’s a little more trickier to write a function that draws a diagonal from lower-left to upper-right for a square picture. Note that the sum of the x and the y should be equal to the number of
What does the following function do? By reading the program without running it, do you think that the result of test9 will be lighter or darker than the result of test7? def test9 (picture): for p in
Write a function to draw a simple face with eyes and a mouth. on a picture.
One of the below programs that when called like this (with the underscore representing a digit from 1 to 4) generates this output:>>> mixem_("we hold these truths")'w.e. .h.o.l.d. .t.h.ese
What is the output from the following?>>> a = ord("A")>>> b = 2>>> x = a * b>>> print x
How many times will the following code print out the message? for x in range (0,5): for y in range (0,10): print "I wil1 be good"
How many times will the following code print out the message? for x in range (1,5): for y in range (0,10,2): print "I will be good"
How many times will the following code print out the message? for x in range (0,3): for y in range (1,5): print "I wil1 be good"
What is the Big-Oh of the method clearBlue?
What is the Big-Oh of the method lineDetect?
Trace through the binary search algorithm in findInSortedList given the following input.findInSortedList("8",["3","5","7","9","10"])
Trace through the binary search algorithm in findInSortedList given the following input.findInSortedList("3",["3","5","7","9","10"])
Trace through the binary search algorithm in findInSortedList given the following input.findInSortedList("1",["3","5","7","9","10"])
Trace through the binary search algorithm in findInSortedList given the following input.findInSortedList("7",["3","5","7","9","10"])
You’ve now seen some examples of class P problems (e.g., sorting and searching), intractable problems (optimization of the song elements), and class NP problems (e.g., the Traveling Salesman
Try something that takes a while in JES (e.g., chromakey on a large image). Use the time module to time how long it takes. Now time the same JES task on several different computers with different
Alan Turing is known for another important finding in computer science, besides the proof that the Halting Problem is unsolvable. He gave us our test for whether a computer has actually achieved
How do people get answers to problems that have algorithms that would take way too long to find the optimal result? Sometimes they use heuristics: rules that don’t lead to a perfect solution, but
Find an algorithm that solves the Traveling Salesman Problem in reasonable run time but isn’t optimal.
The program Watson successfully beat humans at the game Jeopardy. Find articles on the Internet that explain how Watson did it. Does it guarantee that it always finds the best solution?
Here’s a puzzle. You have six blocks. One of them weighs more than the other. You have a scale but you can only use it twice. Find the heaviest one. (a) Write down your process as an
Mathematicians talk about the Fibonacci Sequence, which is a series of numbers defined recursively. The first Fibonacci number is 0, and the second is 1. From there on out, the nth Fibonacci number
Compound interest means that you add the interest (say, 2%) to a starting balance (say, $100) for a period of time (say it’s a year) to get a new balance ($102.00 in this example). During the next
Write a function to convert Celsius to Fahrenheit.
Write a function to convert Farenheit to Celsius.
If you have both of the last two functions (Celsius to Farenheit, and Farenheit to Celsius), are the exact inverses of one another? If you convert 32 degree Farenheit to Celsius, and then back to
Write a function to calculate a person’s body mass index given his/her weight and height.
Write a function to calculate a tip of 20%.
Change the functional turnHairRed() in Program 192 (page 433) into only a single line by recoding the utility functions as lambda functions.
Describe what this function does. Try different numbers as input. def test(num): if num > 0: return test(num-1) else: return 0
Describe what this function does. Try different numbers as input. def test(num): if num > 0: return test(num-1) + num else: return 0
Describe what this function does. Try different numbers as input. def test(num): if num > 0: return test(num-1) * num else: return 0
Describe what this function does. Try different numbers as input. def test (num): if num > 0: return num test(num-1) else: return 0
Using map, increase the value of a sound by applying a function to each sample of the sound.
Describe what this function does. Try different numbers as input. def test(num): if num > 0: return test(num-2) * test(num-1) else: return 0
The makeSamplePage function generates all of the HTML on one line. Inserting the character \n will generate new lines. Put in some newline characters into a new version of that function to create
Using map and filter, maximize a sound—if a sample’s value is greater than or equal to 0, make the sample value 32, 767, and if not, make it −32, 768.
Try writing any other of our sound and picture examples from the earlier chapters functionally, using structures like filter and map.
The makeCatalog function that we create in this chapter has a couple of significant errors.• There should be a space in the title after the colon and before the product name. Fix that.• The
Write a function image that takes an image filename or URL, and a width, then returns the correct img tag for displaying that filename with a given width. Rewrite makeSamplePage to use your new image
Write a function to create a simple home page with your name, your picture, and a table with the titles of your courses and teacher names.
Write a function called riddle that returns a two line string, with a riddle and its answer. Modify makeHomePage to insert the riddle at the end of the page rather than the tagline.
Write a function to create a simple home page with your name, your picture, and your hometown. Provide a link to your home town in a search engine (like Google or Bing) and to a map of your home town
Go to www.half.com and look up a popular movie that they sell as a DVD. What database tables and fields do you think are needed to represent the data for a DVD?
Why should you use a relational database? Are there other kinds of databases? Who invented relational databases?
Do some Web searches to come up with answers to these questions about relational databases:• What is a database table?• What is a join?• What is a query?• What is a connection?
Do someWeb searches to come up with answers to these questions about SQL:• What is SQL?• How do you create a table in SQL?• How do you insert a row in a table in SQL?• How do you get data
Write a function that reads delimited strings from a file with names and phone numbers and uses a database to store the names as the keys and the phone numbers as the values. Take as input the
Create a relational database that has a person table, a picture table, and a person–picture table. In the person table, store an ID, the person name, and the person’s age. In the picture table,
Create a relational database that has a product table, a customer table, an order table, and an order item table. In the product table, store an ID, name, picture, description, and price. In the
Given a relational database with a person table that contains an ID, name, and age. What do each of the following return?• Select * from person.• Select age from person.• Select ID from
Use a hash table to store texting shortcuts and their definitions. For example, “lol” means “laugh out loud.” Use this hash table to decode a text message. Iterate through all the words in
How many frames would you need for a two-hour movie with a picture size of 1024 width by 728 height and 60 frames per second? How much disk space would this movie need if you stored every pixel’s
Look on the Internet for answers to these questions:• How do the AVI and QuickTime movie formats differ?• How do they compare to MPEG4?• When would you want to use each movie format?
Look up “persistence of vision” on the Internet and how it relates to making animations.
Only the first example in this chapter uses the movie object. Rewrite any of the other example programs to create a movie object and return the movie object.
Write a function to create a movie where one item is moving from the top to the bottom and another item is moving from the bottom to the top.
Write a function to create a movie where one item is moving from the left to the right and another item is moving from the right to the left.
Write a function to create a movie where one item is moving in a diagonal line from top left to bottom right and another item is moving from the right to the left.
Create a new movie that has two rectangles moving a random amount (from −5 to 5) in each direction in each frame.
Create a movie that has the frames slowly becoming sepia-toned from left-to-right. Maybe you make sepia-toned the leftmost 10 columns of pixels in the first frame, then the leftmost 20 columns are
Create a movie where an input picture becomes wider and wider with successive frames. For example, the first frame of the movie might just have the middle 5 columns of pixels, then the second frame
Showing 1 - 100
of 410
1
2
3
4
5