Docsity

Python Interpretations - Introduction to Computing | CS 1301, Assignments of Computer Science

Toggle sidebar
bg1
NAME: KEY Section:
Vocabulary (14 pts)
Match each term in the word bank with one of the statements below:
1. Contains printable characters and format sequences that indicate how to format
values
2. A higher-order function that processes a sequence in some order and
accumulates a return value
3. A higher-order function that applies a given function to a sequence of elements
(such as a list) and returns a sequence of results.
4. A higher-order function that processes a sequence (typically a list) in some
order to produce a new data structure containing exactly those elements of the
original data structure for which a given predicate returns the Boolean value of
true
5. The result of a program that python can’t interpret
6. An error occurring while program is executing
7. A program that fails to do what it was intended to do
8. A formal sequence of instructions like a program, or recipe
9. To write a data value in a file along with its type information so that it can be
reconstituted later
10. A named collection of files, also called a folder
11. A user-defined compound type that can be thought of as a template for the
objects that are instances of it
12. The ability to define a new class that is a modified version of a previously
defined class
13. The class from which a child class inherits
14. A single point in a graphic image
1. format string 6. Runtime error 11. class
2. reduce 7. Semantic error 12. inheritance
3. map 8. Algorithm 13. Parent class
4. filter 9. Pickle 14. pixel
5. syntax error 10. Directory
pf3
pf4
pf5

Partial preview of the text

Download Python Interpretations - Introduction to Computing | CS 1301 and more Assignments Computer Science in PDF only on Docsity!

NAME: KEY Section: Vocabulary (14 pts) Match each term in the word bank with one of the statements below:

  1. Contains printable characters and format sequences that indicate how to format values
  2. A higher-order function that processes a sequence in some order and accumulates a return value
  3. A higher-order function that applies a given function to a sequence of elements (such as a list) and returns a sequence of results.
  4. A higher-order function that processes a sequence (typically a list) in some order to produce a new data structure containing exactly those elements of the original data structure for which a given predicate returns the Boolean value of true
  5. The result of a program that python can’t interpret
  6. An error occurring while program is executing
  7. A program that fails to do what it was intended to do
  8. A formal sequence of instructions like a program, or recipe
  9. To write a data value in a file along with its type information so that it can be reconstituted later
  10. A named collection of files, also called a folder
  11. A user-defined compound type that can be thought of as a template for the objects that are instances of it
  12. The ability to define a new class that is a modified version of a previously defined class
  13. The class from which a child class inherits
  14. A single point in a graphic image
  15. format string 6. Runtime error 11. class
  16. reduce 7. Semantic error 12. inheritance
  17. map 8. Algorithm 13. Parent class
  18. filter 9. Pickle 14. pixel
  19. syntax error 10. Directory

Python Interpretations (20 pts) Act like python to interpret the following expression, and it’s type (integer, float, string, Boolean) Expression Result (2pts) Type (2 pts) 7 + 5 12 integer ‘Forty ’ + ‘seven’ Forty seven string 7/4 + 24 + 7**2.0 38 integer 3 < 8 True Boolean (‘a’ < ‘b’) False Boolean

Draw (20 pts) Using your code for mergesort, show how the computer reads and interprets the code to get to the results of [0.5, 3, 5, 7, 8, 14]

[0.5, 7, 11] [3, 5, 8, 14]

[0.5, 3]

[0.5, 3, 5]

[0.5, 3, 5, 7]

[0.5, 3, 5, 7, 8]

[0.5, 3, 5, 7, 8, 11]

[0.5, 3, 5, 7, 8, 11, 14]

Writing Code (20 pts) Write a code that takes a picture and repaints it to have a green tint.

def greenTint():

g=takePicture("color")

for pixel in getPixels(g):

setGreen(pixel, 255)

show(g)