unit 4 comp sci

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

What does the following Python code print? x = 1 while x < 23: x = x + x print(x)

32

Which of the following best describes the result of running the program below? number ← RANDOM (1, 6)REPEAT UNTIL number > 100{ number ← number * 2}IF (number = 128){ DISPLAY (true)}ELSE{ DISPLAY (false)}

If number is a 1, 2 or 4, then the program will display true.

Which of the following statements about lossless image formats, like PNG, and lossy image formats, like JPEG, is true?

Lossy image formats sacrifice detail within an image in order to achieve smaller file sizes.

typecasting

changing the data type of a variable

Which of the following terms specifically refers to images which are stored as a set of digital values called pixels?

raster images

encoding scheme

the conversion of a sequence of characters (letters, numbers, punctuation, symbols, etc.) - the use of code to convert original data into another format

Syntax

the grammatical rules of a programming language

amplitude

the length and width of sound waves - volume or loudness

Consider the following segment of code. IF (num > 10){ num ← num * 2}IF (num < 40){ num ← num / 2}DISPLAY (num) What number, if originally assigned to num, would display the same value for num after executing the above block of code?

15

Consider the following procedures. PROCEDURE math (ans1, ans2){ a ← INPUT() b ← INPUT() c ← math2(a, b) e ← a + ans1 f ← b + ans2 g ← math2(e, f) h ← c + g DISPLAY(h)}PROCEDURE math2 (res1, res2){ d ← res1 + res2 RETURN(d)} What is displayed as a result of executing the following program, if when prompted, the user enters a = 3 and b = 4? math(1, 2)

17

Which of the following is an advantage that text-based programming languages (i.e. Python) have over block-based programming languages (i.e. Scratch)?

Text-based programming languages offer programmers more detailed control over lower-level functionality when writing a program.

Theremin

an electronic musical instrument where tone is generated through high-frequency and the pitch is controlled by hand motions to and from the circuit.

raster format image

an image represented by a grid of pixels - also known as bitmap. Can be scaled down with no quality loss, but when scaling up, can become fuzzy or pixelated.

Central High School has a graphics design course that is developing a historical online archive of the school. The original photos of the school and its history are being digitally scanned and will be placed onto the archival website they are creating. Although the files will be initially scanned in an uncompressed format, the photos uploaded to the website need to have much smaller file sizes and do not need to be of the best quality. Which of the following file formats would be best to use for the photos on the website?

jpg

encoding

the process of putting a sequence of characters (letters, numbers, punctuation, symbols) into a particular format for transmission or storage.

frequency:

the speed of the vibration which determines the pitch of the sound. Measured in wave cycles that occur in one second (Hertz)

modularity

the subdivision of a computer program into separate subprograms

file formats

the way a file is encoded for structure and storage. Denoted with file extensions: .jpg, .gif, .pdf, .mp3, etc.

remix

to alter a piece of media by adding, removing or changing pieces of the original state (re-mash).

sampling rate

the number of samples of sound that can be taken per second to represent the sound digitally.

concatenation

joining together two strings

run

length encoding (RLE) - Lossless data compression where sequences of the same data value are stored as a single value. Example: WWWWWWWWWEEEEEEEE would be compressed to 9W8E

"The <Missing Phrase> structure in Python executes a series of statements continuously for as long as a specified condition is true." Which of the following expressions would best be used in place of <missing phrase> to make the above sentence true?

while

procedural abstraction

provides a name for a process and allows a procedure to be used only knowing what it does, not necessarily how it does it

data abstraction

provides a separation between the abstract properties of a data type and the concrete details of its representation

A programmer completes the user manual for a video game she has developed and realizes she has reversed the roles of "goats" and "sheep" throughout the text. Consider the programmer's goal of changing all occurrences of "goats" to "sheep" and all occurrences of "sheep" to "goats." The programmer will use the fact that the word, "foxes" does not appear anywhere in the original text. Which of the following algorithms can be used to accomplish this?

First, change all occurrences of "goats" to "foxes," then change all occurrences of "sheep" to "goats" and then change all occurrences of "foxes" to "sheep".

In order to be inducted into a school's National Honor Society (NHS), they must meet certain criteria for their GPA, serviceHours and grade. The expression below indicates whether a student has been accepted as a member of the NHS. (GPA ≥ 3.65) AND (serviceHours ≥ 30) AND (NOT grade = 9) Which of the following values would indicate a student that would be accepted into NHS?

GPA = 3.65, serviceHours = 30, grade = 12

Although not all programming environments support documentation in the form of comments, when programmers use one that does support it, they should be adding comments throughout the programming process. Although the comments are ignored by the compiler when executing, they are still useful. Which of the following are true about documentation / comments?

It is used to describe the function of a code segment, procedure or program and how it was developed. It helps in developing and maintaining correct programs when working in an individual or collaborative setting. It provides a way to acknowledge any code segments that were developed collaboratively or by another source (generally this acknowledgement is in the form of the author's name and the origin of the code).

hexadecimal

a base 16 number system comprised of values from 0-9,A-F

bitmap

a file format used to store digital images comprised of a map of bits.

vector format image

a graphic image made up of paths, not a specific number of dots, so they can be rescaled and not lose any image quality.

raw format image

an original image from a digital camera that is neither processed nor compressed and is a larger file format.

input

information collected from the user or external media

what is 1001011 in hexadecimal

4b

What will be displayed after running this section of code: i ← 4REPEAT 4 TIMES{i = i + 1DISPLAY (i)}

5,6,7,8

jpeg format image

a processed and compressed image that is more accessible and generally has a smaller file format.

sampling

a technique for measuring the sound wave and digitally encoding sound to make a digital representation.

data type

describes the values that a variable can hold

A list is a form of data abstraction that helps us to manage the complexity in our program by giving a collection of data a name without the specific details of the representation. What else is true about a list?

Individual elements in a list are typically referenced by using something called an index.

lossless compression

compression that has occurred with no loss of information so when decompression occurs, no data is ever lost if reverting back.

Which of the following is NOT an effective way of finding and correcting errors?

Deleting the code segments are restarting that section of code

What does the following Python code print? You may assume x, y, and z are integers. if y > x: if x < z: print(x) else: print(z) else: if z > y: print(y) else: print(z)

The smallest of the three numbers x, y, and z.

filter

a technique that changes the appearance of an image by altering shades and colors of pixels.

Python Language

a text-based, interpreted, high-level, general-purpose programming language

A gaming console is being programmed to ask questions, such as "Do you love computer science?", of a user when they log into the system. The programmer wants to ensure that the user answers "Yes", so he creates a loop that will re-ask the question if the user answers "No" and continues to repeat the loop until the user answers "Yes." What type of loop would the programmer likely use in this scenario?

a while loop

autotune

digitally transforming out-of-tune bits of an audio file to improve the pitch and sound quality.

output

in a program, this can be anything that is displayed on the screen (text, graphics) or even audio

lossy compression

irreversible compression that uses a more aggressive compression ratio through approximations resulting in partial data loss.

function / method

a pre-defined set of code that can be performed to do a specific task

backmasking

a technique for recording audio backward.

String

A data type consisting of alphanumeric characters between two quotation marks

Which of the following statements is true?

Python is a text-based programming language; therefore, it introduces the possibility of syntax errors.

Consider the following procedures for accessing and modifying the color channels of an RGB pixel. RED (pixel): Extracts the red value from the color of pixel GREEN (pixel): Extracts the green value from the color of pixel BLUE (pixel): Extracts the blue value from the color of pixel SETCOLOR (pixel,r,g,b): Replaces the red, green, and blue values of pixel with new values (r, g, and b, respectively) Using the above procedures, a programmer has written the following code segment to modify image, an array representing the color values for each pixel within an RGB image. FOR EACH pixel IN image{ r ← RED(pixel) g ← GREEN(pixel) b ← BLUE(pixel) avg ← (r + g + b) / 3 SETCOLOR (pixel, avg, avg, avg)} Which of the following best describes the resulting image?

The resulting image will be a grayscale version of the original image.

module

also known as a library, contains procedures and pre-built methods that can be used to simplify our programs

RGB

an additive color model where Red Green and Blue light are added together to produce a variety of colors to display electronically

documentation

text that accompanies a program that explains sections of code, how it works, etc.

Instead of solving a problem using one large code segment, we can base that solution off of the solutions of smaller sub-problems. This is often referred to as modularity. This helps to manage the complexity of the program and can be done in the form of what type of abstraction?

Procedural Abstraction

What is the result of running the following code segment? num ← [1, 2, 3, 4, 5]answer ← 0FOR EACH value IN num{x ← value * 2answer ← answer + x}DISPLAY (answer)

30

compression algorithm

the reduction in the amount of data needed to represent an audio sample.


Set pelajaran terkait

Angles of Elevation and Depression

View Set

Forensic Psychology Week 5 - Psychology of Violence and Intimidation

View Set

NSG 1027 Exam 3 Antepartum and L&D

View Set

1-G - Types of Hazards and Fraud

View Set

The Marketing Mix - Distribution (6.1)

View Set

Exam 1 Chapter 3: The Marketing Environment

View Set

Global History Review 1st Semester

View Set