Scripting exam 1

Ace your homework & exams now with Quizwiz!

In Python, which of the following literals is shown in valid scientific notation? a. 3.0004e-12 b. 17.012s14 c. 0.003x10^-5 d. e12f3.04

a. 3.0004e-12

What is the value of 11 // 2? a. 5 b. 6 c. 0 d. -5

a. 5

What is the result of the expression: int('1750.0')? a. An error: the string does not represent an integer value b. The value 1750 as an int c. The value 1750.0 as a float d. The value '1750' as a string

a. An error: the string does not represent an integer value

Which program can be used to create a Python file that can be used directly by the interpreter? a. IDLE editor b. Word c. Gmail d. Excel

a. IDLE editor

What is an IDE used for? a. Program development, including writing the source code. b. Publishing an app in an app store. c. Searching for open-source applications that perform a specific task. d. Deciding which programming language is best suited for a specific application.

a. Program development, including writing the source code.

Which of the following statements about my_list is false? my_list = ['JFK', 'LAX', 'MIA'] a. The element at index 1 is 'JFK' b. The list has a length of 3 c. The list elements are all strings d. The index of the last item in the list is 2

a. The element at index 1 is 'JFK'

62) What is the value of the __name__ built-in variable in a module that is executed as a script by the programmer? a. __main__ b. __direct__ c. __module__ d. __executed__

a. __main__

Which statement assigns the string variable airport_code with the value JFK? a. airport_code = 'JFK' b. airport_code = JFK c. 'JFK' = airport_code d. JFK = 'airport_code'

a. airport_code = 'JFK'

A sequence of instructions that solves a problem is called _____. a. an algorithm b. a process c. an allegory d. turtle graphics

a. an algorithm

An item passed to a function is a(n) _____ . a. argument b. instruction c. call d. module

a. argument

Dictionaries are containers used to describe a(n) _____ relationship. a. associative b. one-to-one c. recursive d. isolated

a. associative

What is a common word for the textual representation of a program? a. code b. prompt c. interpreter d. expression

a. code

A _____ is a computer component that stores files and other data. a. disk b. monitor c. keyboard d. processor

a. disk

What is the name of the data type used for floating point numbers? a. float b. decimal c. non_integer d. floating_point

a. float

Which function converts a string to an integer? a. int() b. integer() c. string_to_int() d. convert(string, int)

a. int()

A _____ is a word that is part of the Python language and can't be used as a variable name. a. keyword b. special token c. syntax symbol d. stylized word

a. keyword

The operator *= is called a(n) _____ operator. a. double b. compound c. increment d. multiple assignment

b. compound

Which statement makes the code in the math module available? a. use math b. allow math c. import math d. include math

c. import math

Which statement is equivalent to the following assignment? x -= 2 + y a. x = 2 + y - x b. x = -(2 + y) c. x = x - (2 + y) d. x = x - 2 + y

c. x = x - (2 + y)

A processor is a circuit that executes a list of _____. a. bits b. switches c. memories d. instructions

d. instructions

A _____ is a named item used to hold a value. a. constant b. number c. statement d. variable

d. variable

15 _____ 3 = 0 a. % b. / c. // d. *

a. %

Which expression calculates the average of first_num and second_num? first_num = input('Enter the first number: ') second_num = input('Enter the second number: ') a. (float(first_num) + float(second_num)) / 2 b. float((first_num + second_num) / 2) c. (first_num + second_num) / 2 d. float(first_num / 2) + float(second_num / 2)

a. (float(first_num) + float(second_num)) / 2

What is the value of x after the following code is executed? x = 15 x = x + 1 x = x * 2 x = 30 - x a. -2 b. 2 c. 15 d. 32

a. -2

Which floating-point literal correctly represents the scientific notation value: 2.3 x 10^7? a. 2.3e7 b. 2.3*10e7 c. 2.3e10^7 d. 2.3xe7

a. 2.3e7

Objects like integers and strings that can't be modified are called ____. a. immutable b. mutable c. frozen d. set

a. immutable

Which method call returns the number of elements in my_list? a. len(my_list) b. size(my_list) c. my_list.count() d. my_list.size()

a. len(my_list)

Which type of error does not cause the program to crash? a. logic error b. value error c. indentation error d. assignment error

a. logic error

41) Which of the following identifiers is valid? a. max_age b. 32area c. transfer$ d. True

a. max_age

Which of the following assignment statements creates a list with 4 integer elements? a. my_list = [7, 2, -8, 16] b. my_list = [4] c. my_list = ['1', '2', '3', '4'] d. my_list = integer(4)

a. my_list = [7, 2, -8, 16]

Which of the following statements assigns a new variable, my_set, with a set that contains three elements? a. my_set = set([1, 2, 3]) b. my_set = set(3) c. my_set = [1, 2, 3].to_set() d. my_set = { [1, 2, 3] }

a. my_set = set([1, 2, 3])

Basic instruction types are input, process, and _____. a. output b. memory c. calculation d. assignment

a. output

Which print statement would display the letter 'A'? (Note that the code point for the letter 'A' is 65.) a. print(chr(65)) b. print(ord(65)) c. print(unicode(65)) d. print(code_point(65))

a. print(chr(65))

In the statement: age = input('Enter your age: ') , the string 'Enter your age: ' is called a(n) _____. a. prompt b. prefix c. variable d. assignment

a. prompt

Dividing by zero is an example of which type of error? a. runtime b. syntax c. logic d. infinity

a. runtime

What values are in result_set after the following code is run? my_set = {1, 2, 3, 4, 5, 6} other_set = {2, 4, 6} result_set = other_set.difference(my_set) a. { } b. {1, 3, 5} c. {2, 4, 6} d. {1, 2, 3, 4, 5, 6}

a. { }

Which symbol represents the multiplication operation in programming? a. . b. * c. x d. ( )

b. *

Consider the following program: t = 15 t = t * 2 t = t + 1 t = t - 4 put t What does the program produce as output? a. 11 b. 27 c. 12 d. 15

b. 27

Which of the following expressions causes an implicit conversion between types? Assume variable x is an integer, t is a float, and name is a string. a. "Hello, " + str(name) b. 7.5 + (x / 2) c. print(str(t)) d. x + 2 * x

b. 7.5 + (x / 2)

Which type of program converts a high-level language program into machine instructions? a. App b. Compiler c. Processor d. Assembler

b. Compiler

Which statement correctly explains a difference between lists and tuples? a. The built-in function len() works with lists but not with tuples. b. List items can be changed, while tuple items can't be changed. c. List items can be of any type, while tuple types can only be numbers. d. List items use [ ] operators to access items by index, while tuples use ( ) operators to access items by index.

b. List items can be changed, while tuple items can't be changed.

Which of the following statements has a syntax error? Assume age and years are variables that have already been defined. a. age = years - 2 b. age + 2 = years c. age = 17 - 2 d. age = -15

b. age + 2 = years

0s and 1s are known as ___ . a. switches b. bits c. voltage d. electricity

b. bits

A language is called _____ when upper case letters in identifiers are considered different from lower case letters. a. unambiguous b. case sensitive c. case strict d. camel case

b. case sensitive

The special two-item character sequence that represents special characters like \n is known as a(n) _____. a. backslash code b. escape sequence c. unicode spec d. literal character

b. escape sequence

Which statement changes the value associated with key "Lemon" to 0.75 in the dictionary fruits_dict? a. fruits_dict[0.75] = "Lemon" b. fruits_dict["Lemon"] = 0.75 c. fruits_dict[Lemon] = 0.75 d. dict("Lemon") = fruits_dict[0.75]

b. fruits_dict["Lemon"] = 0.75

The built-in Python function that gives an object's identity is: a. memory() b. id() c. type() d. identity()

b. id()

Which data type is the correct choice to store a student's test scores in chronological order? a. string b. list c. set d. dict

b. list

Which statement removes the last element of my_list a. my_list.pop(len(my_list) b. my_list.pop(len(my_list)-1) c. my_list.remove(len(my_list)) d. my_list.remove(len(my_list)-1)

b. my_list.pop(len(my_list)-1)

What does print("one\\two\\\\three") display? a. one\\two\\\three b. one\two\\three c. one twothree d. one\\\\two\\\\\\\\three

b. one\two\\three

The Python language is developed by a public community of users, therefore Python is a(n) _____ language. a. buggy b. open-source c. open-space d. beginner

b. open-source

Assigning a value to a floating point variable that is too large for the computer to represent is a condition called _____ . a. bit error b. overflow c. overcapacity d. system error

b. overflow

Which statement outputs the text: "I won't quit!"? a. print(I won't quit!) b. print("I won't quit!") c. print('I won't quit!') d. print('I won't quit!', punctuation=True)

b. print("I won't quit!")

Which instruction displays variables or expression values? a. put() b. print() c. output() d. display()

b. print()

Which print statement displays the value of a variable called argv in a module called sys? a. print(argv in sys) b. print(sys.argv) c. print(sys_argv) d. print(module sys var argv)

b. print(sys.argv)

Which pair shows the correct classification of the given data type? a. tuple, mutable sequence type b. string, immutable sequence type c. int, numeric floating-point type d. dict, immutable sequence type

b. string, immutable sequence type

According to Python's precedence rules, which of the following operators has the highest precedence? a. subtraction - b. unary - c. * d. +

b. unary -

Which statement reads a user-entered string into variable user_name? a. input = user_name() b. user_name = input() c. input() => user_name d. user_name = "input()"

b. user_name = input()

Which statement has a syntax error? Assume variables x, y, z, and age have already been defined. a. y = y b. x + y = z c. age = '32' d. print('Name, age')

b. x + y = z

Which expression using parentheses is equivalent to the following expression: x - y * -z / 3 a. (x - y) * ((-z) / 3)) b. x - ((y * (-z)) / 3) c. x - (y * ((-z) / 3)) d. (x - (y * (-z))) / 3

b. x - ((y * (-z)) / 3)

Which code example is an expression? a. x = 4 b. print(x) c. (x * y) / 2 d. # Display x

c. (x * y) / 2

15 _____ 3 = 5.0 a. % b. ^ c. / d. //

c. /

What is displayed when the following code is executed? empty_string = '' print(len(empty_string)) a. "empty" b. 1 c. 0 d. "0"

c. 0

What is the ending value of z? x = 0.3 z = math.pow(math.ceil(x), 2) a. 0.0 b. 0.09 c. 1.0 d. 1.09

c. 1.0

What is the value of y after the following code is executed? Note that the question asks for y, not x. x = 10 y = x + 2 x = 12 a. 8 b. 10 c. 12 d. 14

c. 12

What is the output? my_list = [2, 8, 3, 1, 18, 5] print(my_list[3] + my_list[1] * 2) a. 7 b. 10 c. 17 d. 18

c. 17

The Python language began development in the late _____'s. a. 1940 b. 1960 c. 1980 d. 2010

c. 1980

What is the value of: 1 + int(3.5) / 2? a. 2 b. 2.25 c. 2.5 d. 3

c. 2.5

Which of the following is not a valid expression? Assume x and y are integer variables. a. x / (y * 7) b. y / x * 2 c. 2x + 3y d. (x - 3*y)

c. 2x + 3y

_____ is the process where objects that are no longer needed are deleted. a. Identity recycling b. Memory clearing c. Garbage collection d. Object recycling

c. Garbage collection

RAM is an abbreviation that stands for: a. Real Analog Memory b. Ranged Access Memory c. Random Access Memory d. Random Abbreviated Memory

c. Random Access Memory

What is Moore's Law? a. A processor used in cold weather is more likely to fail b. Every action has an equal and opposite reaction c. The capacity of ICs doubles roughly every 18 months d. Any given program will become obsolete

c. The capacity of ICs doubles roughly every 18 months

What are the contents of names_list after the following code is executed? names_list = ['one', 'two', 'three'] digits_list = ['1', '2', '3'] names_list = names_list + digits_list a. ['1one', '2two', '3three'] b. ['two', 'four', 'six'] c. ['one', 'two', 'three', '1', '2', '3'] d. ['1', '2', '3', 'one', 'two', 'three']

c. ['one', 'two', 'three', '1', '2', '3']

Assume a and b are variables that hold the base and height of a right triangle. The length of the long side (hypotenuse) is calculated as the square root of a^2 + b^2. Which expression calculates the length of the hypotenuse? a. math.square_root(a * a + b * b) b. math.sqrt(math.pow(a * a), math.pow(b * b)) c. math.sqrt(math.pow(a, 2)) + math.pow(b, 2))) d. math.pow(math.sqrt(a), 2) + math.pow(math.sqrt(b), 2)

c. math.sqrt(math.pow(a, 2)) + math.pow(b, 2)))

Which statement is true regarding the pop() method for sets? a. pop() removes the first item added to the set. b. pop() removes the last item added to the set. c. pop() removes a random item in the set. d. pop() returns but does not remove a random item in the set.

c. pop() removes a random item in the set.

Which statement does not print a newline character at the end? a. print('First part...') b. print('First part...\n') c. print('First part...', end='') d. print('First part...', end="-\n")

c. print('First part...', end='')

The variable emails_dict is assigned with a dictionary that associates student ids with email addresses. Which statement prints the email address associated with the student id "C2104"? a. print(value of emails_dict("C2104")) b. print(key of emails_dict("C2104")) c. print(emails_dict["C2104"]) d. print(emails_dict["[email protected]"])

c. print(emails_dict["C2104"])

Which print statement would display 'C:\Users\Mika\grades.txt' (without the single quotes)? a. print(r'C:\/Users\/Mika\/grades.txt') b. print(r'C:\'Users\'Mika\'grades.txt') c. print(r'C:\Users\Mika\grades.txt') d. print(r'C:\\Users\\Mika\\grades.txt')

c. print(r'C:\Users\Mika\grades.txt')

Which data type is the correct choice to store the names of all the hockey players who have scored 3 or more goals in a single game in no specific order? a. int b. tuple c. set d. list

c. set

In an instruction like: z = x + y, the symbols x, y, and z are examples of _____. a. output b. visibles c. variables d. instructions

c. variables

Which symbol is used in Python to create a comment? a. * b. C c. // d. #

d. #

If text_line = 'one fish two fish', what is the value of text_line[6]? a. ' ' b. 'h' c. 'i' d. 's'

d. 's'

Which statement about Python is true? a. Linux and Mac computers usually do not come with Python installed. b. There are no free web-based tools for learning Python. c. Windows usually comes with Python installed. d. Developers are not usually required to pay a fee to write a Python program.

d. Developers are not usually required to pay a fee to write a Python program.

Which of the following data values is best represented with a floating point variable? a. The number of pets in a house. b. The number of acorns in a tree. c. The number of children in a classroom. d. The speed of a snail.

d. The speed of a snail.

Which runtime error type occurs when trying to convert 'abc' to an integer? a. TypeError b. LogicError c. NameError d. ValueError

d. ValueError

Which of the following symbols can be used as part of an identifier? a. @ b. $ c. & d. _ (underscore)

d. _ (underscore)

Because Python 2.7 programs cannot be run by the Python 3.0 interpreter, Python 3.0 is not _____. a. open-source b. a scripting language c. standalone d. backwards-compatible

d. backwards-compatible

Which of the following statements removes the value 'Google' from the set, companies? companies = { 'Apple', 'Microsoft', 'Google', 'Amazon' } a. companies.pop(2) b. companies.pop('Google') c. companies.remove(2) d. companies.remove('Google')

d. companies.remove('Google')

Which statement removes entry "1G1JB6EH1E4159506" from the dictionary cars_dict? a. cars_dict["1G1JB6EH1E4159506"] = None b. cars_dict{"1G1JB6EH1E4159506"}.del() c. delete(cars_dict["1G1JB6EH1E4159506"]) d. del cars_dict["1G1JB6EH1E4159506"]

d. del cars_dict["1G1JB6EH1E4159506"]

Which data type is the correct choice to store the number of wins associated with each basketball team in the NBA? a. float b. string c. tuple d. dict

d. dict

The formula for calculating the amount of interest charged on a loan is: interest = [principal x rate] of interest x time Which Python statement correctly performs the interest calculation? a. interest = [principal * rate_of_interest] * time b. interest = principal * rate of interest * time c. interest = principal x interest x time d. interest = (principal * interest) * time

d. interest = (principal * interest) * time

A(n) _____ is a program that executes a script. a. app b. compiler c. processor d. interpreter

d. interpreter

A _____ can be located in a dictionary and is associated with a value. a. value b. pair c. list d. key

d. key

The _____ is a process that manages programs and interfaces with peripherals. a. clock b. BIOS c. integrated circuit d. operating system

d. operating system

Which print statement would display: I won't quit! a. print('I won\\'t quit!') b. print('I won't quit!') c. print('I won\'\t quit!') d. print('I won\'t quit!')

d. print('I won\'t quit!')

Which line in the following program causes a runtime error? sales = { "apples": 0, "lemonade": 0 } sales["apples"] = sales["apples"] + 1 del sales["lemonade"] print(len(sales["apples"])) a. sales = { "apples": 0, "lemonade": 0 } b. sales["apples"] = sales["apples"] + 1 c. del sales["lemonade"] d. print(len(sales["apples"]))

d. print(len(sales["apples"]))

Which expression gives the number of whole minutes that corresponds to some number of seconds? a. seconds % 60 b. seconds / 60 c. seconds * 60 d. seconds // 60

d. seconds // 60

Which of the following statements produces an error? Assume string_1 = 'abc' and string_2 = '123'. a. string_2 = string_1 b. string_1 = string_2 + "456" c. print(string_1 + string_2) d. string_1[1] = 'B'

d. string_1[1] = 'B'

Space, tab, and newline are all called _____ characters. a. noprint b. symbol c. space-line d. whitespace

d. whitespace

What values are in result_set after the following code is run? my_set = {1, 2, 3, 4, 5, 6} other_set = {2, 4, 6} result_set = my_set.union(other_set) a. { } b. {1, 3, 5} c. {2, 4, 6} d. {1, 2, 3, 4, 5, 6}

d. {1, 2, 3, 4, 5, 6}


Related study sets

PMK-EE E7 LEADERSHIP AND CHARACTER EXAM

View Set

Independent Study Test SM-004 #2

View Set

Oklahoma State Licensing Closed Circuit Television Test

View Set

Anatomy and Physiology 2 Final Exam

View Set