Bus Programming Practice Quiz

Which of the following translates a high-level language program into low-level machine instructions?Machine InstructionApplicationAssembly LanguageCompiler

Compiler

x = 35y = x + 20x = 50What is assigned to y?55502035

55

What is the datatype of z when the following statements are executed?x = [1,2,3,4,5]y = tuple(x)z = x[3]print(z)floatlisttupleinteger

Integer

What is displayed when the following code executes?x = 25print("x")this causes an error2525xx

x

What data type is created by the following statement?a = (1, "15" , 22.2 , "hello")floatstringlisttuple

tuple

What is the datatype of z when the following statements are executed?x = ['1' , 2 , 3 . 0 , '4' , 5]y = tuple(x)z = x[3]print(z)tupleliststringfloat

string

What method adds an element to the end of a list?popappendThis is not possibleremove

append

What is the datatype of luckynumber after the following statement is executed?luckynumber = input("What is your favorite number? ")floatliststringinteger

string

What is displayed when the following statements are executed?x = [1,2,3,4,5]y = tuple(x)z = x[3]print(z)4the code results in an errorz3

4

What statement removes the third element in the tuple assigned to the name ATPplayers?ATPplayers.pop(2)This is not allowedATPplayers.pop(3)ATPplayers[2]

This is not allowed

What expression changes:user_ages = [99,33,66]to[99,66]user_ages.pop(0)user_ages.pop[2]user_ages.pop(1)user_ages.pop[3]

user_ages.pop(1)

What is the value of y after all the following statements execute?x = (10,20,30,40)x = list(x)x.append(50)y = x[5]5040The code will return an error10

The code will return an error

Does the following statement create an immutable data type?scores = ('love',15,30,40,'NYC')yesno

yes

What will be displayed on screen after the following statement executes, given that total_grade = 95?print("Your final grade is: "+str(total_grade)+ ".")a Your final grade is: total_grade.b Your final grade is:95c Your final grade is: 95.d Your final grade is : 95 .

C

The list ['a', 'b', 3] is valid.FalseTrue

TRUE

Which of the following is a valid variable name?numCars3rd_placethird_place!num cars

numCars

What is the value of y when all of the following statements execute?x = ('King James' , 23 , 'MJ' , 23 , 'Black Mamba' , 24)x = list(x)x[5] = 8x = tuple(x)y = len(x)85King James6

6

What will be displayed on screen given that TotalCostwTax = 500print("Total cost plus tax:","$ {:,.4f}".format(TotalCostwTax)+".")a Total cost plus tax: $500.0000.b Total cost plus tax: $500.00!c Total cost plus tax: $ 500.0000.d Total cost plus tax: $ 500.0000

c

What will be displayed on screen, given that byear = "1987"print("You were born in the year:")print(byear[0])print(byear[1])print(byear[2])print(byear[3])

You were born in the year:1987

Which line below has the first error?1. egrades = [90,100,80,85,80]2. pgrades = tuple(egrades)3. newgrade=float(input())4. pgrades.append(newgrade)5. tot=sum(pgrades)6. items=len(pgrades)

4

Given the variable num_books = 20, which statement prints the following?We have 20 books to lend out!a print("We have",num_books,"books to lend out!")b print("We have",num_books," to lend out!")c print("We have",20,"books to lend out!")d print("num_books")

a

What is displayed when the following statements are executed?x = [1,2,3,4,5]y = tuple(x)z = x[3]print(z)34zthe code results in an error

4

What is the datatype of luckynumber after the following statement is executed?luckynumber = input("What is your favorite number? ")stringintegerfloatlist

String

Which of the following is a valid assignment statement?dog age = 102019dog_age=10dog_age = 1010=dog_age

dog_age = 10

What is displayed when the following code executes?x = 25print("x")x25xthis causes an error25

x

Which is an expression that accesses the last character of a string assigned to the variable name my_school.my_school(0)my_school[9]my_school[0]my_school[-1]

my_school[-1]

What data type is created by the following statement?teams = ['Raiders','Niners','Cowboys','Saints']liststringintegertuple

list

What statement removes the third element in the tuple assigned to the name ATPplayers?This is not allowedATPplayers.pop(3)ATPplayers[2]ATPplayers.pop(2)

This is not allowed

What will be displayed on screen after the following statement executes, given that total_grade = 95?print("Your final grade is: "+str(total_grade)+ ".")a Your final grade is: 95.b Your final grade is:95c Your final grade is : 95 .d Your final grade is: total_grade.

a Your final grade is: 95.

What datatype is created with the following statement?workrecord = ['Joe' , 10000 , 'James' , 12000, 25.45, '2000']listtuplestringinteger

list

What error is generated by the following statement?int("Thursday")Type ErrorValue ErrorSyntax ErrorName Error

Value Error

What expression changes:user_ages = [99,33,66]to[99,66]user_ages.pop(1)user_ages.pop[3]user_ages.pop(0)user_ages.pop[2]

user_ages.pop(1)

What will be displayed on screen after the following statement executes, given that total_grade = '80'?print('Your final grade is '+total_grade+' out of 100 possible points')a Your final grade is 80 out of 100 possible pointsb Your final grade is80out of 100 possible pointsc Your final grade is total_grade out of 100 possible pointsd The code will result in an error

a Your final grade is 80 out of 100 possible points

What is the value of y when all of the following statements execute?x = ('King James' , 23 , 'MJ' , 23 , 'Black Mamba' , 24)x = list(x)x[5] = 8x = tuple(x)y = len(x)86King James5

6

What print statement will print the following on screen?Given thatheight = 60weight = 120bmi = 24.333333333333332With a height of 60 and weight of 120 your BMI is 24.333333333333332a print(With a height of , "height" , and weight of , "weight" , your BMI is, "bmi")b print("With a height of"+height+"and weight of"+weight+"your BMI is"+bmi)c print("With a height of" , height , "and weight of" , weight , "your BMI is" , bmi)d print("With a height of",60,"and a weight of",120,"your BMI is",BMI)

c print("With a height of" , height , "and weight of" , weight , "your BMI is" , bmi)

What will be displayed on screen given that TotalCostwTax = 500print("Total cost plus tax:","NTD{:,.2f}".format(TotalCostwTax))a Total cost plus tax: NTD 500.00b Total cost plus tax: NTD500.00!c Total cost plus tax: NTD500.00d Total cost plus tax: NTD500.000

c Total cost plus tax: NTD500.00

Which line below has the first error?1. egrades = [90,100,80,85,80]2. pgrades = tuple(egrades)3. newgrade=float(input())4. pgrades.append(newgrade)5. tot=sum(pgrades)6. items=len(pgrades)35no error in code4

4