Computer Science Final (S2)

Ace your homework & exams now with Quizwiz!

What is output by the following code? for x in range (4): for y in range (3): print ("*", end=" ") print ("\n")

* * * * * * * * * * * *

Consider the following code: start = int(input("Enter the starting number: ")) stop = int(input("Enter the ending number: ")) x = 6 for i in range (start, stop, x): print (i, end=" ") What is output if the user enters 12 then 36?

12 18 24 30

Consider the following code: start = int(input("Enter the starting number: ")) stop = int(input("Enter the ending number: ")) x = -10 sum = 0 for i in range (start, stop, x): sum = sum + i print(sum) What is output if the user enters 78 then 45?

252

Consider the following code: phrase = "Big Data means processing massive data sets. " print (phrase.find("data")) What is output?

34

What is output by the following code? sum = 0 for i in range (3, 15, 3): sum = sum + i print ("Sum = " +str( sum))

Sum = 30

Information sent to a function is a?

parameter

Which function tells Python to handle a value as a string?

str()

Active memory is __________ and __________.

temporary, fast

We use loops ________________________.

to repeat a section of code

____________ : A way to spot errors in code and predict output.

tracing code

The _____________ method changes strings to uppercase letters.

upper()

What are the two ways to end a loop?

~Using user input ~Count variable

When do you use a for loop instead of a while loop? (There may be more than one answer)

~You know how many times you want the loop to run. ~When there is a defined start and end.

Consider the following code: h = [8, 4, 5, 1, 1, 6, 7, 9, 3, 3, 9, 3] print (h[1]) What is output?

4

Consider the following code: def calc(num1, num2 = 0): print(num1 + num2) #MAIN val1 = int(input(" ")) val2 = int(input(" ")) print(calc(val1, val2)) What s output when the user enters 19 and 18?

37

Consider the following program: def sample(val): val = val - 8 #MAIN n = 38 sample(n) print(n) What is output?

38

Consider the following code: print (str(9) + str(75)) What is output?

975

Consider the following code: def tryIt(b): b = b + 100 #**********MAIN*********** x = 99 print (x) tryIt(x) print (x) What is output?

99 and 99

This HTML tag is used to add links to web pages

<a>

Which of the following pairs of tags cannot be used to make text bold

<em></em>

This HTML tag is used to add images to webpages

<img>

This HTML tag defines a section of text. All whitespace in the section of text is ignored and a blank line is placed after the closing tag

<p>

Which tag is used to create paragraphs?

<p>

What is output by the following line of code? print(mystery("hello"))

False

What is output by the following line of code? print(mystery("zip code: 12345"))

False

Trace the code. What does the program do?

Finds the largest positive number of the numbers entered

Module 6 Finish

Finish

Module 7 Finish

Finish

A loop with the count variable built in.

For Loop

What's the body of an HTML file?

The area where the page content is stored.

Why do we output to data files?

To save the output a program generates

Every device on a network has its own IP address.

True

A swap is:

an algorithm exchanging two values stored in variables

Two-dimensional arrays are really:

an array of arrays

Which of the following CORRECTLY opens a file for output?

infile = open("sample.txt", "w")

What data type are the indexes in stuff?

int

What is output by the following code? for x in range (10): print (x, end=" ")

0 1 2 3 4 5 6 7 8 9

What is output by the following code? for x in range (25, 5, -2): print (x, end=" ")

25 23 21 19 17 15 13 11 9 7

Consider the following code: grid = [] grid.append([63, 59, 25, 86, 86, 24, 31] ) grid.append([17, 28, 67, 68, 44, 27, 33] ) grid.append([24, 31, 28, 67, 68, 44, 27] ) What are the dimensions of the two-dimensional array?

3 x 7

What is output when the user enters 9?

56

Currently we are transitioning to IP version __________.

6

What is output by the following code? def mult(a, b = 2, c = 1): print (a * b * c) print(mult(3))

6

What is output by the following program? def sample(val): val = val * 10 #MAIN n = 6 sample(n) print(n)

6

_________________ is information sent to a function.

A parameter

Why do we use the term binary to describe information sent over the Internet

Because the binary number system uses only two numbers, 0 and 1.

Which of the following carries out the commands of running programs?

Central Processing Unit

Range is an example of a...

Function.

Packets are _____________.

Information sent over the Internet that is broken into individual pieces.

What is output by the following program? def greeting(name = "?") return "Hello " + name + "!" #MAIN print(greeting("Joe"))

None of the above. The code has an error.

Method that adds elements on to the end of an array.

append()

Consider the following code: word = "benevolent pigeon" print (word.replace("e", "*")) What is output?

b*n*vol*nt pig*on

When we digitize information we represent it in ____________

binary

Consider the following program: def sillyString(w): return w.replace( "a", "oo") #MAIN fruit = input ("Enter a fruit: ") print(sillyString(fruit)) What is output if the user enters "banana"?

boonoonoo

We ____________ a functions when we type its name.

call

Capitalizes the first letter

capitalize

To create the body of a function, we ____________ the code.

indent

An array in Python.

list

Returns the ASCII value of a character

orlando racist department

Considering the following code: x = [1,0,6,3] y = [5,8,1,2] for i in range(len(x)): print("(" + str(x[i]), + "," + str(y[i]) + ")") This code prints out (x,y) coordinate pairs. It is an example of using ______________ arrays.

parallel

Using more than one array to store related data is called _____________ arrays.

parallel

Compression is ______________.

reducing the size of information

Removes an element by value, removes the first instance.

remove

What is output by the following program? def mult(a, b = 1, c = 1): print(a * b * c) print(mult(2, 5))

10

What is output by the following code? for x in range(7, 16): print(x * 2, end=" ")

14 16 18 20 22 24 26 28 30

What is output by the following program? def sample(val): val = val - 8 #MAIN n = 16 sample(n) print(n)

16

How many for loops does it take to sort numbers (using the sorting algorithm covered)?

2

What is output when the user enters 3?

26

What is output if the user enters 7?

28

Consider the following code: stuff = ["dog", "cat", "frog", "zebra", "bat", "pig", "mongoose"] c = 0 for i in range(len(stuff)): c = c + len(stuff[i]) print (c) What is output?

29

Consider the following code: ar = [] ar.append ([29, 21, 33, -30]) ar.append ([39, 26, -43, 42]) ar.append ([123, 43, 33, 46]) for r in range(len(ar)): for c in range(len(ar[0])): print (ar[r][c], end=' ') print ("") How many rows does the array have?

3

Consider the following code: grid = [] grid.append (["frog", "cat", "hedgehog"]) grid.append (["fish", "emu", "rooster"]) print (grid) How many columns does this array have?

3

For questions 31 - 34 refer to the following code: max = 0 for i in range (10): n = int(input("Enter a number: ")) if (n >= 0 and n > max): max = n print (max) How many variables are in the program?

3

Put the following steps in order: 1) Content from the IP address is loaded 2) Computer uses DNS to look up the domain name 3) Type in the URL 4) IP address is fetched

3, 2, 4, 1

Consider the following code: ar = [] ar.append ([29, 21, 33, -30]) ar.append ([39, 26, -43, 42]) ar.append ([123, 43, 33, 46]) for r in range(len(ar)): for c in range(len(ar[0])): print (ar[r][c], end=' ') print ("") How many columns does the array have?

4

Consider the following code: phrase = "Big Data means processing massive data sets. " print(phrase.find("D")) What is output?

4

What is output if the user enters -5?

4

What list of numbers is created by the following code? range(4, 11)

4 5 6 7 8 9 10

How many unique addresses are there using IPv4?

4 billion

Put the following steps in order: 1) Content from the IP address is loaded 2) Computer uses DNS to look up the domain name 3) IP address is fetched 4) Type in the URL

4, 2, 3, 1

Consider the following code: temp = [] temp.append ([25, 38, 47, 47, 24, 50, 20, 48, 46, 24, 21, 32, 40]) temp.append ([50, 20, 48, 46, 24, 21, 32, 40, 44, 47, 25, 22, 29]) temp.append ([21, 32, 40, 44, 47, 25, 22, 29, 26, 39, 43, 30, 49]) print (temp[1][2]) What is output?

48

Consider the following code: import simplegui def draw_handler(canvas): for r in range (10, 60, 10): canvas.draw_circle((50, 50), r, 3, 'Red') frame = simplegui.create_frame('For Loops', 100, 100) frame.set_draw_handler(draw_handler) frame.start() How many circles does this draw? ______

5

Consider the following code: values = [] for i in range(5): values.append(int(input("Next number: "))) print (values) If the line print (len(values)) is appended to this code, what is output by that print (len(values)) line?

5

When a website asks your browser for a secure connection over the Secure Sockets Layer (SSL), which of the following acts as a digital ID card that verifies that the website really is the one it claims to be?

A digital certificate

A protocol is __________.

A set of rules and standards

Transmission Control Protocol is _____________.

A set of rules that manage how information is sent over the Internet.

Which of the following can a character NOT contain?

A string

A precise set of rules for how to solve a problem.

Algorithm

What is output by the following code: for i in range(41, 31, -1): print(i) What is output?

All numbers from 41 to 32 counting counting backwards.

Consider the following code: def mystery (v, w): print (w.upper() + " - " + v.lower()) #MAIN val1 = input("Enter a word: ") val2 = input("Enter a word: ") print (mystery (val1, val2)) What is output if the user enters cat then dog?

DOG - cat

______________ means to set a variable equal to a known value.

Initialize

Allows an entire array to be created with stored values at the same time.

Initializer test

What is one advantage of using external data files?

Inputting large amounts of data from a file instead of the keyboard.

What is output by the following program? def test(): print("Inside the function") #MAIN test() print("In main") print("done.")

Inside the function In main done.

______________ is a network of networks.

Internet

What is the primary use of functions?

To organize longer programs.

Why do we use external data files?

To process large amounts of data

What would happen if only negative numbers are entered in the program?

Zero is output.

Consider the following code: print("zip code: 10036".capitalize())

Zip code: 10036

Consider the following code: def mystery (a): for i in range(len(a)): j = a[i] a[i] = j.replace("a", "@") # ********** MAIN ********** stuff = ["Juneau", "Atlanta", "Helena", "Madison", "Annapolis", "Topeka"] mystery(stuff) print(stuff) What is output?

['June@u', 'Atl@nt@', 'Helen@', 'M@dison', 'Ann@polis', 'Topek@']

Consider the following: stuff = ["dog", "cat", "frog", "zebra", "bat", "pig", "mongoose"] "frog" is ____________.

an element

A(n) ____________ is a variable that holds many pieces of data at the same time.

array

Consider the following code: sample (a, b, c = 7, d) Which of the parameters is optional?

c

Which of the following parameters is optional? sample(a, b, c = 7, d)

c

Consider the following code: grid = [] grid.append (["frog", "cat", "hedgehog"]) grid.append (["fish", "emu", "rooster"]) What is output by: print (grid[0][1])

cat

______________ can be individual letters, digits or symbols.

characters

The ___________ command changes an ASCII value to its character.

chr()

The <head> of an HTML file ____________________.

contains information about the file

Which of the following parameters is optional? sample(a, b, c, d = 0)

d

Adds several elements to the end of the array.

extend

The ___________ method adds a list onto the end of the array.

extend

Location of the data in an array.

index

Which of the following built-in functions returns the ASCII code representation of an input character?

ord()

The following loop is intended to print the numbers 1, 2, 3, 4, 5. Fill in the blank: for i in _____ (1, 6): print (i)

range

Which range function will generate a list of all even numbers between 12 and 84 inclusive?

range (12, 86, 2)

Which range function will generate a list with all odd numbers between 3 and 17 inclusive?

range (3, 18, 2)

The ___________ keyword is used to return a value from a function.

return

For Questions 3-5, consider the following code: stuff = [] stuff.append("emu") stuff.append("frog") stuff.append("iguana") print (stuff) What data type are the elements in stuff?

string

To create a two-dimensional array which of the following are NOT correct?

stuff = [][]

Consider the following array: stuff = ["dog", "cat", "frog", "zebra", "bat", "pig", "mongoose"] for i in range(len(stuff)): print (______) To print the words in the arrays in all UPPERCASE you would replace the ____________ with:

stuff[i].upper()

The ___________ go above the ___________ in the source code file.

subprograms, main program

In a swap you need a _____________ variable so that one of the values is not lost.

temp

Consider the following code: for i in range (x, y, z): print (i, end=" ") What values for variables x, y, and z will produce the output below? 26 24 22 20 18 16 14 12 10

x = 26 y = 8 z = -2

Consider the following code: for i in range (x, y): print (i, end=" ") What values for variables x and y will produce the output below? 5 6 7 8 9 10 11 12 13 14

x = 5 y = 15

The _____________ is the address of a piece of data.

index

A ____________ is a command used to repeat code.

loop

Information sent to a function.

Parameter

Suppose we add the following line of code to our program: print(mystery(x)) What is output when the user enters 1, 1, and 1?

-1

Which symbol marks a closing tag?

/

Which of the following would NOT be stored using an array?

A first name

Chart assigning each character a number value so it can be stored in memory.

ASCII

Variable that holds many pieces of data at the same time.

Array

_____________ is storing a specific value in the array.

Assigning

Consider the following code: print ("at 10 am the phone rang. i answered.".capitalize()) What is output

At 10 am the phone rang. i answered.

What is an Internet Fast Lane

Bandwidth set aside for specific data

A network of private computers infected with malicious software and controlled as a group without the owner's knowledge

Botnet

Consider the following program: def test_1(): test_3() print("A") def test_2(): print("B") test_1() def test_3(): print("C") What is output by the following line of code? test_1()

C A

___________ the file saves the data outputted by the program.

Closing

Location back and forth in an array. Starts at 0.

Column

__________ __________ are used to represent a real world situation using a computer.

Computer Models

_______________ help us look at new situations and try to measure how change impacts things.

Computer models

A for loop is used to replace a ________ while loop.

Counting

____________ is protecting against the criminal or unauthorized use of electronic data, or the measures taken to achieve this

Cybersecurity

When hackers overwhelm a website with too many requests

Denial of service account

Yeah

U stinkwad

Functions go _____________ the main program in the source code file.

above

Which range function creates the following list of numbers? 24 27 30 33 36 39

range(24, 42, 3)

For Questions 115-118, consider the following code: def mystery1(x): return x + 2 def mystery2(a, b = 7): return a + b #MAIN n = int(input("Enter a number:")) ans = mystery1(n) * 2 + mystery2 (n * 3) print(ans) What is output when the user enters -4?

-9

What does it mean that arrays are row major?

...

Consider the following code: phrase = "Python" print(phrase.find("P")) What is output?

0

Consider the following code: start = int(input("Enter the starting number: ")) stop = int(input("Enter the ending number: ")) x = -6 sum = 0 for i in range (start, stop, x): sum = sum + i print(sum) What is output if the user enters 10 then 20?

0

Consider the following code that stores values in a 5 x 3 array called grid: grid = [] grid.append (["frog", "cat", "hedgehog"]) grid.append (["fish", "emu", "rooster"]) grid.append (["dog", "bird", "rabbit"]) grid.append (["deer", "chipmunk", "opossum"]) grid.append (["fox", "coyote", "wolf"]) f = 0 for r in range (len (grid)): for c in range (len(grid[0])): f = f + 1 grid[r][c] = r * c What is the array re-initialized to after running the code?

0 0 0 0 1 2 0 2 4 0 3 6 0 4 8

What list of numbers is created by the following code? range(8)

0 1 2 3 4 5 6 7

What is output when the user enters -2?

1

What is output by the following code? for x in range (3, 18): print (x - 2, end=" ")

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Consider the following code: start = int(input("Enter the starting number: ")) stop = int(input("Enter the ending number: ")) x = 3 for i in range (start, stop, x): print (i, end=" ") What is output if the user enters 11 then 18?

11 14 17

What is output by the following code? for x in range (8, 16): print (x * 2, end=" ")

16 18 20 22 24 26 28 30

What is output by the following code? for i in range (17, 8, -2): print (i, end=" ")

17 15 13 11 9

Consider the following code: start = int(input("Enter the starting number: ")) stop = int(input("Enter the ending number: ")) x = -5 sum = 0 for i in range (start, stop, x): sum = sum + i print (sum) What is output if the user enters 18 then 13?

18

For Questions 112-114, consider the following program: def tryIt(a, b = 7): return a + b #MAIN n = int(input('Enter a number: ')) ans = tryIt(n) * 2 print (ans) What is output if the user enters 2?

18

Consider the following code: def calc(num1, num2 = 0): print(num1 + num2) #MAIN val1 = int(input(" ")) val2 = int(input(" ")) print(calc(val1)) What is output when the user enters 19 and 18?

19

Consider the following code: def sample (val): val = val + 5 #MAIN n = 19 sample(n) print(n) What is output?

19

Consider the following code: grid = [] grid.append (["frog", "cat", "hedgehog"]) grid.append (["fish", "emu", "rooster"]) print (grid) How many rows does this array have?

2

To iterate through (access all the entries of) a two-dimensional arrays you need _________ for loops. (Enter the number of for loops needed).

2

What is output by the following code? print (chr(50))

2

Consider the following code: grid = [] grid.append( []) grid [0].append (9) grid [0].append (7) grid [0].append (5) grid [0].append (3) grid.append( []) grid [1].append (2) grid [1].append (8) grid [1].append (1) grid [1].append (3) How many rows and columns does this array have?

2 rows 4 columns

Suppose we add the following line of code to our program: print(mystery(x, y)) What is output when the user enters 5, 8, and 2?

3

What is output by: print (len (stuff))

3

For questions 1-5, consider the following code: nums = [30, 10, 30, 14, 10, 3, 9, 7] print (nums) -------------------- nums.extend([24, 3, 21, 19]) print (nums) What is output by the above code's last print statement?

30, 10, 30, 14, 10, 3, 9, 7, 24, 3, 21, 19]

For questions 123-127, consider the following code: def mystery(a, b = 8, c = -6): return 2 * b + a + 3 * c #MAIN x = int(input("First value: ")) y = int(input("Second value: ")) z = int(input("Third value: ")) Suppose we add the following line of code to our program: print(mystery(x, y, z)) What is output when the user enters 4, 3, and 7?

31

Consider the following code: temp = [] temp.append ([25, 38, 47, 47, 24, 50, 20, 48, 46, 24, 21, 32, 40]) temp.append ([50, 20, 48, 46, 24, 21, 32, 40, 44, 47, 25, 22, 29]) temp.append ([21, 32, 40, 44, 47, 25, 22, 29, 26, 39, 43, 30, 49]) print (temp[2][1]) What is output?

32

Suppose we add the following line of code to our program: print(mystery(x, y, z)) What is output when the user enters 8, 6, and 4?

32

Most IPv4 addresses today are ______ bits long, divided into 4 sections of ______ bits each.

32, 8

Consider the following code: def mystery (a, b = 8, c = -6): return a + b + c #MAIN x = int(input("First value: ")) y = int(input("Second value: ")) z = int(input("Third value: ")) print (mystery (x, y, z)) What is output when the user enters 30, 2 and 2?

34

What is the largest number you can use with the <h> tags

6

What is output by the following program? def mult(a, b = 1, c = 1): print(a * b * c) print(mult(2, 5, 6))

60

Consider the following code: def mystery (a): for i in range(len(a)): if (a[i] % 2 ==0): print (a[i]) # ********** MAIN ********** s = [63, 72, 21, 90, 64, 67, 34] mystery(s) What is output?

72 90 64 34

Consider the following code: tests = [78, 86, 83, 80, 89, 92, 91, 94, 67, 72, 80, 95] c = int(input("Cutoff value: ")) n = 0 for i in range(len(tests)): if (tests[i] >= c): n = n + 1 print ("Values above " + str (c) + ": " + str(n)) What is output when the user enters 80?

9

If net neutrality is not adopted, which of the following strategies would be most likely to enable Internet Service Providers to make additional money?

Allowing some content to travel to internet users faster than other content

ASCII stands for: _______ _______ _______ _______ _______

American Standard Code for Information Interchange.

In an array, what is the difference between an element and an index?

An element refers to actual data within the array while an index refers to a memory location.

Which of the following will be most likely to increase the speed at which information travels from a server to a student's laptop?

An increase in the bandwidth of the network

In an array the element is _______________.

An individual piece of data stored in an array.

___________ allows an entire array to be created with stored values at the same time.

An initializer list

Consider the following code that works on an array of integers: for i in range(len(values)): if (values[i] <0): values[i] = values [i] * -1 What is does it do?

Changes all negative numbers to positives.

Routers are _____________.

Devices that manage traffic on the Internet.

DNS stands for _____________.

Domain Name System

A way of using a method on an object like a string.

Dot Notation

What is the role of the Domain Name System (DNS) in internet communications

Each computer and server is identified by its own IP address so before requests can be sent to a server, the DNS provides the IP address associated with website names.

Why aren't electrical signals used to transmit all data on the internet?

Electrical signals can fade after travelling short distances

End of Unit 10

End

Unit 9 End

End

Communication protocols are a set of rules that are agreed to by all parties that have been designed in order to

Ensure that new technologies and devices that haven't been invented yet can all use the same methods of communication

What is output by the following code? def mystery(w): if (w.upper() == w): return "TRUE" else: return "FALSE" print(mystery("Hello there!"))

FALSE

An array stores data using multiple variable names.

False

Because there is typically only one pathway available for each packet of of information traveling over the internet, if any server on a given route fails, the information will not reach its destination. T/F

False

Consider the following code: val = "The temperature is 82 degrees Fahrenheit." print(val.isdigit())

False

Currently in the US, ISPs can block access to content at will. T/F

False

Data on the internet travels in a fixed path from sender to receiver.

False

It is not possible for an array to hold an array.

False

Our searching algorithm returns the element that we're searching for, rather than the index of the element we're searching for.

False

The range function must have two parameters?

False. ~Range has three possible sets of parameters: range(stop) - Returns 0 to the given stop value, counts by one. range(start, stop) - Returns numbers from the given start value to the given stop value, counts by one. range(start, stop, step) - Returns numbers from the given start value to the given stop value, counts by the given step.

Loop with the count variable built in.

For loop

A collection of commands that are given a name.

Function

A variable available to all methods

Global variable

Unit 8 Finish

Hacer DONE

HTML Stands for __________ __________ __________ __________.

Hyper Text Markup Language

A(n) ____ is the location of a computer on a network

IP Address

What is output by the following code? def test(): print("Inside the sub") #MAIN print("In main") test() print("done.")

In main Inside the sub done.

What is output by the following program? def subtractOne(n): n = n - 1 print ("In the function: " + str(n)) #Main value = 5 subtractOne(value) print("In main: " + str(value))

In the function: 4 In main: 5

Set a variable equal to a known value.

Initialize

____________ means to set a variable equal to a known value before a loop.

Initialize

IP stands for ____________ ____________?

Internet Protocol

ISP stands for _____________ _____________ _____________

Internet Service Provider

Consider the following code: def mystery (a): for i in range(len(a)): if (i % 2 ==0): print (a[i]), # ********** MAIN ********** stuff = ["Juneau", "Atlanta", "Helena", "Madison", "Annapolis", "Topeka"] mystery(stuff) What is output?

Juneau Helena Annapolis

What is Net Neutrality

Keeping access to all data equal

Why do we use for loops with arrays?

Lets us quickly process contents of the array.

Programming command used to repeat code.

Loop

A variable used to stop a loop from repeating.

Loop Control Variable

___________ compression is when data is lost in the compression, while ____________ compression is when no information is lost and the original can be restored exactly.

Lossy; lossless

The central part of the program.

Main

We call the central part of the program ____________.

Main

What does the n >= 0 do in the program?

Makes sure only positive numbers are compared to max.

Using random numbers made by computers to test computer models.

Monte Carlo Methods

_________ _________ _________ use random numbers made by computers to test computer models.

Monte Carlo Methods

What is output by the following program? def greeting(name): print("Hello ", name.upper()) greeting("Sara")

None of the above. The code has an error.

Which of the following can be sent in one piece over the internet?

None of the items listed. Each one is made up of hundreds of thousands of bits, so each must be broken into packets to be sent over the internet

Which of the following parameters is optional? sample(a, b)

None of the parameters are optional

Consider the following code: def mystery (a): for i in range(len(a)): if (a[i] % 2 ==0): print (a[i]), # ********** MAIN ********** stuff = ["Juneau", "Atlanta", "Helena", "Madison", "Annapolis", "Topeka"] mystery(stuff) What is output?

Nothing is output, you cannot do modular division on strings.

Why do we use two for loops with two-dimensional arrays?

One to move over the rows, and one for the columns.

Which of the following is the first step needed when writing a program designed to get data from an external data file?

Open the file.

Suppose we used our searching algorithm to look for a specific element in a list. The algorithm returned -1. What does this mean?

Our algorithm did not find the element we were looking for.

A way of representing data across several arrays.

Parallel Arrays

A variable used to send information to a subprogram.

Parameter

Emails designed to trick users into sharing private information

Phishing

Consider the following code: words = ["This", "is", "a", "sentence"] for word in range(len(words)): print(words[word]) What does this code do?

Print out, on separate lines, each word in the list

Returns a set of numbers.

Range Function

A variable used to add up a list of numbers.

Represent a real world situation using a computer.

What does the "mystery" function do?

Returns TRUE if there are no letters in the string.

Location up or down in an array. Starts at 0.

Row

Row address comes fist

Row-major

Row-major means:

Rows come first in the index

You know what, Ryan Smelly Belly?

Screw You

An algorithm used to find a value in an array.

Search

Run experiments using computer models.

Simulation

____________ run experiments using computer models.

Simulations

Why do we use for loops with arrays?

Since an array has an exact length you know exactly how many time a loop will need to repeat.

Put a set of values into an order.

Sort

______________ is when a hacker taps into the DNS and changes an entry to point at the wrong IP address.

Spoofing

A collection of commands that are given a name

Subprogram

A ___________ variable is used to add up a set of values.

Sum

To exchange two values stored in variables.

Swap

The commands in between the < > are called _____________.

Tags

What is displayed in a browser if you leave off a closing tag in your HTML code? For example: <h2>Section 1

The browser shows the page content but the formatting is incorrect.

Consider the following code: for range (15, 88): print (x) What is wrong with this program?

The first line should be for x in range(15, 88):

Consider the following code: for x (7, 10): print (x) What is wrong with the program?

The first line should be for x in range(7, 10):

What is wrong with the following code? for range(7, 10): print(x)

The first line should be for x in range(7, 10):

Open the W3 Schools editor found at the following link: https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_paragraphs1 (Links to an external site.)Links to an external site. In the editor change the first instance of <p>This is a paragraph.</p> to <p align = center>This is a paragraph.</p> Then, hit the "Run" button to view how your updated HTML impacts the content displayed. What happens?

The first line that says "This is a paragraph." is now centered horizontally on the screen.

Why are IP addresses that are longer than 32-bits being assigned

The four billion addresses available under the IPv4 protocol will all be used at some point in the future. The new, longer addresses are needed to ensure that the supply of addresses will be greater than the demand for addresses.

Change <img src="smiley.gif" alt="Smiley face" width="500" height="500"> To <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b9/Rainbow_Trout.jpg/1920px-Rainbow_Trout.jpg" alt="trout">

The image is replaced with a large image of a trout

Which of the following is NOT true about functions?

They go below the main program in the source code file.

Which of the following is NOT a rule for algorithms?

They repeat indefinitely.

Message to Ryan

This card and the two before it are not answers. Don't put it on the test, silly

Why do we do stuff = [ ] before using an array?

This creates the variable and lets Python know it is an array.

In the future, more and more IPv6 web addresses will be issued. T/F, why?

This is true because in the future there will not be enough IPv4 to meet the world's need for IP addresses

Which tag is used to change the name of your page in the browser?

Title

Which of the following is NOT a reason we use subprograms?

To add comments to lines of code.

Which of the following is NOT a use of computer simulations:

To calculate the area of an oval room

Which of the following is NOT a reason to use arrays?

To do number calculations.

Which of the following applies to functions and describes a reason we use functions?

To enable code to be reused.

We use loops...

To repeat a section of code.

Why do we use functions?

To simplify code.

Where does append add the new elements?

To the end of an array.

Reading through code to find errors and predict results.

Tracing Code

Reading through code to find errors and predict results.

Tracing code

What of these describes markup languages?

Transforms text into the images, links, tables, and lists that make up web pages and other documents.

A browser's job is to ______________.

Translate HTML code to a webpage we see on the screen.

Consider the following code: val = "58742" print (val.isdigit()) What is output?

True

Disguising a virus as a security update is a common way of infecting a computer. T/F

True

For Questions 119-121, consider the following code: def mystery(w): if (w.upper() == w.lower()): return "TRUE" else: return "FALSE" What is output by the following line of code? print(mystery(")(&#444$"))

True

Net Neutrality is a political issue. T/F

True

Net Neutrality is an issue around the world. T/F

True

The <h> tags include a return at the end of the line. T/F

True

Array with both rows and columns.

Two-dimensional array

An array is:

Variable that holds many pieces of data at the same time.

A piece of code that is capable of copying itself and typically has a detrimental effect, such as corrupting the system or destroying data

Virus

Consider the following code: def volume(x, y, z): return x * y * z #MAIN v = 0 length = int(input("Length: ")) width = int(input("Width: ")) height = int(input("Height: ")) v = volume(length, width, height) print("Volume:", v) What is the output if the user enters 3, 7, 2?

Volume: 42

Computer simulations were first developed during as a part of the

WWII, Manhattan Project

nums.insert(3, -89) print (nums) What is output by the above code if it were substituted for the last 2 lines of code?

[30, 10, 30, -89, 14, 10, 3, 9, 7]

nums = [30, 10, 30, 14, 10, 3, 9, 7] nums.pop(1) nums.pop(1) print (nums) What is output by the above code?

[30, 14, 10, 3, 9, 7]

nums = [30, 10, 30, 14, 10, 3, 9, 7] nums.remove(10) print (nums) What is output by the above code?

[30, 30, 14, 10, 3, 9, 7]

Consider the following code: def tryIt(b): for i in range(len(b)): b[i] = b[i] + 100 #***********MAIN************ x = [] x = [56, 78, 88] print (x) tryIt(x) print (x)

[56, 78, 88] and [156, 178, 188]

Consider the following code: def mystery (a): for i in range(len(a)): a[i] = a[i] * 100 # ********** MAIN ********** ar = [84, 11, 67, 70, 93, 39, 46, 27] mystery(ar) print (ar) What is output?

[8400, 1100, 6700, 7000, 9300, 3900, 4600, 2700]

Consider the following code: s = [63, 72, 21, 90, 64, 67, 34] s.sort(reverse = True) print(s) What is output?

[90, 72, 67, 64, 63, 34, 21]

Which of the following is used to mark the end of the line in a text file?

\n

The ___________ method adds a new element onto the end of the array.

append

The ___________ method adds a new item onto the end of the array.

append

In two-dimensional arrays the ___ is always listed second.

column

Creates a method.

def

The __________ keyword creates the function.

def

The __________ keyword is used to create a function.

def

Which method correctly swaps two rows of an array?

def swapRows (grid, a, b): if ( a >=0 and a < len(grid)): if ( b >=0 and b < len(grid)): for c in range(len(grid[0])): temp = grid[a][c] grid[a][c] = grid[b][c] grid[b][c] = temp

In an HTML file, the <body> tag _______.

defines the contents of the document body, containing items such as text, hyperlinks, images, tables and lists

random mc spotten

dot dot dotten

A(n) ___________ is an individual piece of data in an array.

element

A(n) ____________ is a piece of data stored in an array.

element

Data stored in an array.

element

When information is sent over the internet in a secure manner, hackers are unlikely to be able to access it because ________.

encryption techniques mean that even with the world's most sophisticated computers, hackers will need many years to find the security keys that will enable them to gain access to encrypted information sent over the internet.

Which loop initializes the array grid to the following values? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

f = 0 for r in range (len (grid)): for c in range (len(grid[0])): f = f + 1 grid[r][c] = f

Suppose that you need to access a data file named "students.txt" to hold student names and GPAs. If the user needs to look at the information in the file, which command could be used to open this file?

f = open('students.txt', 'r')

Tells if a string contains a value.

find

A ______ loop has a built in count variable.

for

Which of the following is NOT an example of a Python built-in function?

for

Write the code to initialize a 4 x 3 array to the values: 1 2 3 1 2 3 1 2 3 1 2 3 Assume the array called values is already declared and initialized as a 4 x 3 array.

for r in range (len (values)): for c in range (len(values[0])): values[r][c] = c + 1

Consider the following code: vals = [] Which loop correctly builds a 14 x 17 array initialized to random 2-digit numbers?

for r in range(14): vals.append([]) for c in range(17): vals[r].append (random.randint(10,99))

Consider the following code: grid = [] grid.append (["frog", "cat", "hedgehog"]) grid.append (["fish", "emu", "rooster"]) What is output by: print (grid[0][0])

frog

A ____________ is a collection of commands given a name.

function

A ___________ variable is available to all methods in a program.

global

Two-dimensional arrays are used to store data that can be represented in a _____________.

grid

Two-dimensional arrays store information that can be represented as a ___.

grid

Consider the following code: grid = [] grid.append (["frog", "cat", "hedgehog"]) grid.append (["fish", "emu", "rooster"]) print (grid[0][2]) What is output?

hedgehog

Consider the following code: start = int(input("Enter the starting number: ")) stop = int(input("Enter the ending number: ")) for i in range (start, stop): print (i, end=" ") What variable is the loop control variable in this program?

i

Consider the following code: price = [12.99, 10.00, 2.50, 1.99] This code is an example of a(n) ______________ _____________.

initializer list

Inserts elements into an array and resizes the arrays.

insert

Tells if a string is all numbers.

isdigit

The _____________ method returns the length of an array.

len

The __________ command returns the length of a string.

len()

Consider the following code: tests = [78, 86, 83, 89, 92, 91, 94, 67, 72, 95] sum = 0 for i in range(_____): sum = sum + tests[i] print ("Class average: " + str(1.0*(sum/_____))) What should go in the ____________ to make sure that the code correctly finds the average of the test scores.

len(tests)

In Python an array is called a ______________.

list

In Python arrays are also called ____________.

lists

A variable that exists only inside a method.

local variable

Consider the following code: start = int(input("Enter the starting number: ")) stop = int(input("Enter the ending number: ")) for x in range (start, stop): print (x) In this program, x is an example of a ______________.

loop control variable

Sorting algorithms are used to ___________ arrays, while search algorithms ___________ in arrays.

order, find

We use arrays in programs to ______________ data.

organize

Functions are used to ____________.

organize longer programs.

A ___________ is a variable used to pass information to a method.

parameter

A variable used to send information to a function is called a ___________.

parameter

A variable used to send information to a subprogram is called a _______________.

parameter

Removes an element by location.

pop

Consider the following function: def avg(a, b, c = 0): if (c ==0): print(1.0 * (a + b)/2) else: print(1.0*(a + b +c)/3) Which of the following calls is NOT correct?

print (avg ( 88))

Consider the following Python function definition: def mult(a, b = 1, c = 1): print(a * b * c) Which of the following calls is NOT correct?

print (mult(9, 15, 6, 7))

Which range function will create a list with all odd numbers between 5 and 77?

range(5, 78, 2)

Which range function creates the following list of numbers? 76 74 72 70 68 66 64 62

range(76, 60, -2)

The ___________ method removes elements from an array by the value not the location.

remove

The _____________ keyword tells the subprogram what value to return.

return

keyword that tells the subprogram what value to send back.

return

Consider the following code: grid = [] grid.append (["frog", "cat", "hedgehog"]) grid.append (["fish", "emu", "rooster"]) What is output by: print (grid[1][2])

rooster

In two-dimensional arrays the ___________ is always listed first.

row

Two-dimensional array indexes are listed as ____________ and _________

rows, columns

When using for loops and two-dimensional arrays the outside loop moves across the ___________ and the inside loop moves across the ___________.

rows, columns

An algorithm used to find a value in an array is called a ______________.

search

Sorts the elements of an array.

sort

The _____________ algorithm requires two for loops.

sort

Consider the following two-dimensional array: 11 25 57 97 50 67 22 45 89 38 42 12 98 73 41 88 61 82 71 62 44 27 97 54 98 88 76 77 29 66 93 12 46 12 87 95 38 82 22 35 35 26 18 83 97 73 13 26 12 94 66 42 74 78 32 53 43 10 72 10 Which loop correctly adds the values in the fourth column (i.e. the column accessed by index 3)?

sum = 0 for r in range(len(a)): sum = sum + a[r][3]

Which of the following best describes HTML

the markup language used to create web pages

Consider the following code: def tryIt(s): temp = "" for i in range(len(s)): if(s[i] == "e"): temp = temp + "@" else: temp = temp + s[i] print (temp) # ********** MAIN ********** f = "to be or not to be" tryIt(f) What is output?

to b@ or not to b@

Changes the string to upper case.

upper

Radio waves are ___________

used to send bits wirelessly

The ____________ command sends information to the file.

write()

Consider the following code: stuff = ["dog", "cat", "frog", "zebra", "bat", "pig", "mongoose"] print(stuff[3]) What is output?

zebra

When do you use a for loop instead of a while loop? (Select multiple answers)

~ You know how many times you want the loop to run ~When there is a definite starting and ending point

When do you use a for loop instead of a while loop? (Select multiple answers)

~ You know how many times you want the loop to run. ~When there is a definite starting and ending point.

Pick multiple answers: The two ways of ending a loop are:

~Count variable ~User input


Related study sets

AH2 - Exam 1 - Lippincott 11ed - Test 4 - Client with an Upper Respiratory Tract Infection

View Set

Ch 42: Drug Therapy for Hyper and Hypothyroidism

View Set

Chapter 3 Spread spectrum technology

View Set

Anatomy and Physiology II: Lecture Exam One

View Set