COMP 1220 final -MC

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Which symbol is used in Python to create a comment ?

#

If text_line = ' one fish two fish ' , what is the value of text_line [ 6 ] ?

' s '

What values are in result_set after the following code is run ?

( 1 , 2 , 3 , 4 , 5 , 6 }

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 : ' )

( float ( first_num ) + float ( second_num / 2

Which code example is an expression ?

( x * y ) / 2

Which operator is evaluated first : x + y < y - z * 2 ?

*

Which symbol represents the multiplication operation in programming ?

*

What is the value of x after the following code is executed ?

-2

What are the possible values for random.randint ( -4 , 4 ) ?

-4 ... 4

What are the possible values for random.randint ( -4,4 ) ?

-4 ... 4

15___ 3 = 5.0

/

What is displayed when the following code is executed ?

0

What is displayed when the following code is executed ? empty_string = " " print ( len ( empty_string ) )

0

What is the ending value of a when b is assigned with the value 5 ?

0

What are the possible values for random.randrange ( 6 ) ?

0 ... 5

What is the base 2 representation of the decimal number : 12 ?

00001100

What is the value of x after the following code is executed ?

1

What is the ending value of z ?

1.0

What is x's final value ? x = 10 y = 20 if y < = 2 * x : X = x + 5 else : x = x * 2

15

The Python language began development in the ..... late ' s .

1980

Which of the following is not a valid expression ? Assume x and y are integer variables

2x + 3y

What is the base 10 representation of the binary number 00101110 ?

46

What is the value of 11 // 2 ?

5

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 .

7.5+ ( x / 2 )

What is the value of x after the following code is executed ? 0 x = 7 If x < 7 X - X + 1 x = x + 2

9

What is the result of the expression : int ( ' 1750.0 ' ) ?

An error : the string does not represent an integer value

What is the result of the expression int ( 1750.0 ' ) ?

An error : the string does not represent an integer value

What is output when the following code is executed ? score 65 group = if score < - 60 : group group + ' A ' if score < 70 : group group + ' B ' if score < = 80 : group group + ' C ' else : group group + ' D ' print ( group )

BC

Which type of program converts a high - level language program into machine instructions ?

Compiler

Which statement about Python is true ?

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

Which program can be used to create a Python file that can be used directly by the interpreter ?

IDLE editor

Which statement correctly explains a difference between lists and tuples ?

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

Which type of error does not cause the program to crash ?

Logic error

The... is a process that manages programs and interfaces with peripherals

Ooperating system

What is an IDE used for ?

Program development , including writing the source code

What is an IDE used for ?

Program development , including writing the source code .

RAM is an abbreviation that stands for :

Random Access Memory

What is Moore's Law ?

The capacity of ICs doubles roughly every 18 months

Which of the following statements about my_list is false ?

The element at index 1 is ' JFK '

Which of the following data values is best represented with a floating point variable ?

The speed of a snail .

Which runtime error type occurs when trying to convert ' abc ' to an integer ?

ValueError

Which formatting presentation type is used to display the integer 43 as OX2b ( hexadecimal in uppercase ) ?

X

What is the value of the name built - in variable in a module that is executed as a script by the programmer ?

__main__

An item passed to a function is a ( n ) ------

argument

Dictionaries are containers used to describe a ( n ) —- relationship .

associative

0's and 1's

bits

A language is called when upper case letters in identifiers are considered different from lower case letters .

case sensitive

What is a common word for the textual representation of a program ?

code

Which of the following statements removes the value ' Google ' from the set , companies ?

companies.remove ( ' Google ' )

The operator *= is called a ( n ) . operator .

compound

Which formatting presentation type is used to display an integer ?

d

Which statement removes entry " 1G1JB6EH1E4159506 " from the dictionary cars_dict ?

del cars_dict [ " 1G1JB6EH1E4159506 " ]

A ..... is a computer component that stores files and other data .

disk

The built - in Python function that gives an object's identity is :

id ( )

The built - in Python function that gives an object's identity is :

id ()

A processor is a circuit that executes a list of -----

instructions

Which function converts a string to an integer ?

int ()

The formula for calculating the amount of interest charged on a loan is : interest = [ principal x rate of interest ] x timeWhich Python statement correctly performs the interest calculation ?

interest ( principal* rate_of_interest * time

A ( n ) is a program that executes a script .

interpreter

A can be located in a dictionary and is associated with a value .

key

Which method call returns the number of elements in my_list ?

len ( my_list )

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 ?

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

Which of the following identifiers is valid ?

max_age

Which of the following statements assigns a new variable , my_set , with a set that contains three elements ?

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

What does print ( " one \\ two \\\\ three " ) display ?

one \ two \\ three

The Python language is developed by a public community of users , therefore Python is a ( n ) ________ language .

open - source

Basic instruction types are input , process , and

output

Which statement outputs the text : " I won't quit ! " ?

print ( " I won't quit ! " )

Which print statement would display : I won't quit !

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

Which print statement would display the letter ' A ' ? ( Note that the code point for the letter ' A ' is 65. )

print ( chr ( 65 ) )

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 " ?

print ( emails_dict [ " ( 2104 " ] )

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 " ?

print ( emails_dict [ " ( 2104 " ] )

Which print statement displays : ' Tokyo had 9.273000 million people in 2015 ?

print ( f ' { " Tokyo " : s } had ( 9.273 : f } million people in { 2015 : d } ' )

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 " ] ) )

print ( len ( sales [ " apples " ] ) ) ,

Which print statement would display ' C : \ Users \ Mika \ grades.txt ' ( without the single quotes ) ?

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

Which print statement displays the value of a variable called argv in a module called sys ?

print ( sys.argv )

Which statement does not print a newline character at the end ?

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

In the statement : age = input ( ' Enter your age : ' ) the string ' Enter your age : ' is called a ( n ) __________

prompt

Which expression is most appropriate for randomly choosing a day of the week ?

random.randrange ( 7 )

Which statement , executed once , enables a program to generate the same sequence of pseudo - random numbers from random module methods each time the program is run ?

random.seed ( 10 )

Dividing by zero is an example of which type of error ?

runtime

Which expression gives the number of whole minutes that corresponds to some number of seconds ?

seconds // 60

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

set

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 ?

set

Which pair shows the correct classification of the given data type ?

string immutable sequence type

Which of the following statements produces an error ? Assume string_1 = ' abc ' and string_2 = ' 123 '

string_1 [ 1 ] = ' B '

According to Python's precedence rules , which of the following operators has the highest precedence ?

unary

Which statement reads a user - entered string into variable user_name ?

user_name = input ( )

In an instruction like : z = x + y , the symbols x , y , and z are examples of ----

variables

Which statement correctly creates a new tuple west_cities with elements Vancouver ' , ' Portland ' , ' Eugene ' in that order ?

west cities = ( ' Vancouver ' , ' Portland ' , ' Eugene )

Space , tab , and newline are all called ———— characters .

whitespace

Which statement has a syntax error ? Assume variables x , y , z , and age have already been defined .

x + y= z

Which expression using parentheses is equivalent to the following expression : x - y * -z / 3

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

Which statement is equivalent to the following assignment ? x -= 2 + y

x = x- ( 2 + y )

What values are in result_set after the following code is run ?

{}


Kaugnay na mga set ng pag-aaral

Anatomy S2B3 - Cardiac Embryology

View Set

Topic 4 Properties of Matter - Lesson 3 States of Matter

View Set

Yak - Chapter 12 Employee Dissatisfaction and Grievances

View Set