BUS 92 MC Final

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

What would be displayed on screen, given the following code? user_name2 = 'erehwon' for name_letter2 in reversed(user_name2): print(name_letter2) print("The End!") A. n o w h e r e The End! B. nowhere The End! C. e r e h w o n The End! D. n The End! o The End! w The End! h The End! e The End! r The End! e The End!

A. n o w h e r e The End!

What is the value of y after the following statements execute? y = 125 x = y%10 A. 125 B. 12.5 C. 12 D. 5

A. 125

What is displayed on screen after the following statements execute? y = (5,10,15,20) x = sum(y) print(x) A. 50 B. (5,19,15,20) C. The code will return an error D. [5,10,15,20]

A. 50

What is the value of y when all of the following statements execute? x = ('King James',23,'MJ',23,'Black Mamba',24) y = len(x) A. 6 B. 4 C. 3 D. 70

A. 6

What is relatively small, volatile storage with fastest access located on a processor chip. A. Cache B. RAM C. Disk D. Operating System

A. Cache

What will be the last line displayed on screen when the following code is executed? user_string2 = ('k','l','m','n','o','p') for letter2 in reversed(user_string2): print(letter2) print("Done!") A. Done! B. k C. p o n m l k D. p

A. Done!

What text is added to the material already displayed on-screen when the user enters n in response to the question Continue (y/n)? answer = 'y' while answer != 'n': s = input("Song?") print(s) answer = input("Continue (y/n)?") print("Thank you for playing") A. Thank you for playing B. Nothing is added to the material displayed on screen C. Song? D. Continue (y/n)?

A. Thank you for playing

What is assigned to x when all of the following statements have executed? x = ['King James',23,'MJ',23,'Black Mamba',24] x[5] = 8 A. ['King James',23,'MJ',23,'Black Mamba',8] B. ['King James',23,'MJ',23,'Black Mamba',24] C. ('King James',23,'MJ',23,'Black Mamba',8) D. ['King James',23,'MJ',23,8,24]

A. ['King James',23,'MJ',23,'Black Mamba',8]

What is the data type of the value assigned to y as the result of the following statements? y = '66' y = int(y) y = float(y) A. float B. string C. list D. integer

A. float

What loop is best to use when the number of iterations is computable before entering the loop, as when counting down from X to 0, printing a string N times, etc. A. for loop B. while loop

A. for loop

What print statement will print the following on screen? Given that height = 60 weight = 120 bmi = 24.333333333333332 Congrats, your BMI is 24.333333333333332 A. print('Congrats, your BMI is',bmi) B. print('Congrats, your bmi is ',bmi) C. print('Congrats, your BMI is'+bmi) D. print('Congrats, your BMI is',bmi)

A. print('Congrats, your BMI is',bmi)

What print statement will display the following on screen? Given the following data: itemQuantity = 5 itemName = Pineapple itemPrice = 1.0 The unit price of Pineapple is $ 1.0 print('The unit price of',itemName,'is $',itemQuantity) A. print('The unit price of',itemName,'is $',itemPrice) B. Print('The unit price of',itemName,'is $',itemPrice) C. print('The unit price of',itemName,'is',itemPrice) D. print('The unit price of',itemName,'is $',itemQuantity)

A. print('The unit price of',itemName,'is $',itemPrice)

Which range function will generate the sequence of numbers from zero to 99? A. range(100) B. range(0,100,2) C. range(99) D. range(0,99,1)

A. range(100)

A website lists the calories expended by men and women during exercise as follows: Men: Calories = [(Age × 0.2017) — (Weight × 0.09036) + (Heart Rate × 0.6309) — 55.0969] × Time / 4.184 Women: Calories = [(Age × 0.074) — (Weight × 0.05741) + (Heart Rate × 0.4472) — 20.4022] × Time / 4.184 What is one way you would edit the text above to write it in programming notation? A. replace spaces in variable names with underscores B. change Calories to calories C. replace parentheses with square brackets D. place parentheses around Time/4.184

A. replace spaces in variable names

The following is an example of what type of error? print('Today is Monday") A. syntax error B. type error C. name error D. value error

A. syntax error

What is another way of writing the following using python code? x+=500 A. x = x + 500 B. x = x - 500 C. x + 500 = x D. x = 500

A. x = x + 500

How many parameters are required by the draw_square function in the code below? cr = '#' def draw_square(size): for h in range(size): for w in range(size): print(cr, end='') print() def draw_rect(height, width): for h in range(height): for w in range(width): print(cr, end='') print() A. none of the options listed B. 1 C. 0 D. 2

B. 1

What user input would result in the following output, given the following if-elif-else statements: You are ok to view G movies! That's all folks! age2 = input() age2 = int(age2) if age2 <= 9: rating = 'G' elif age2 <= 12: rating = 'PG' elif age2 <= 16: rating = 'PG-13' else: rating = 'R' print("You are ok to view "+rating+" movies!") print("That's all folks!") A. 16 B. 9 C. 12 D. 10

B. 9

Given the following code: cheer = "Go Warriors!" for cheerl in cheer: print(cheerl) for cheerr in reversed(cheer): print(cheerr) print("The entered cheer was:",cheer) What is the last line displayed on screen when this code is executed? A. G B. The entered cheer was: Go Warriors! C. ! D. The entered cheer was: !sroirraW oG

B. The entered cheer was: Go Warriors!

What line needs to be added to the following code below so that the following will be displayed on screen: max_sum is: 17.0 the code: def find_max(num_1, num_2): max_val = 0.0 if (num_1 > num_2): max_val = num_1 else: max_val = num_2 return max_val num_a = 5.0 num_b = 10.0 num_y = 3.0 num_z = 7.0 max_sum = 0.0 a = find_max(num_a,num_b) b = find_max(num_y,num_z) A. max_sum=num_a+num_y B. print('max_sum is:', a+b) C. a+b D. print(max_sum)

B. print('max_sum is:', a+b)

How would you call the following function: def print_shape(): print('***') print('***') print('***') return to display 9 lines of 3 asterisks, such as: *** *** *** *** *** *** *** *** *** A. print_shape('***') B. print_shape() print_shape() print_shape() C. print_shape() print_shape() D. print_shape(9)

B. print_shape() print_shape() print_shape()

What data type is created with the following statement? z = '55' A. float B. string C. integer D. list

B. string

The following is an example of what type of error? lyric = 99+"bottles of pop on the wall" A. value error B. type error C. name error D. syntax error

B. type error

What python standard library module could be used to: Retrieve the contents of the webpage zybooks.com A. random B. urlib C. os D. math

B. urlib

What will be displayed on screen given the following code? for i in range(4): print(i * 2) A. 0 1 2 3 4 B. 0 1 2 3 C. 0 2 4 6 D. 0 2 4 6 8

C. 0 2 4 6

What will be displayed on screen when the following code executes? num_puppies = 4 if num_puppies != 4: print('b') else: print('d') print('g') A. d B. g C. d g D. b g

C. d g

How many parameters are there in the pyramid_volume function called in the following code? print('Volume for 4.5,2.1,3.0 is:',pyramid_volume(4.5,2.1,3.0)) A. none B. 2 C. 3 D. 1

C. 3

What is the final value of employee_bonus given value of num_sales is 2 if num_sales == 0: employee_bonus = 0 elif num_sales == 1: employee_bonus = 2 elif num_sales == 2: employee_bonus = 5 else: employee_bonus = 10 A. 10 B. 2 C. 5 D. 0

C. 5

What is the value of x after all of the following statements execute? x = [10,20,30,40] x.pop(0) x=sum(x) A. 10 B. [20,30,40] C. 90 D. Statements result in an error

C. 90

What will be displayed on screen if the user input is 2000 user_num7 = input() user_num7 = int(user_num7) if user_num7 == 2001: print(user_num7,': Twin Towers') elif user_num7 == 2008: print(user_num7,': Great Recession') elif user_num7 == 2017: print(user_num7,': Hurricane Maria') else: print('No Disasters!') A. Hurricane Maria B. Twin Towers C. No Disasters! D. Great Recession

C. No Disasters!

What will be displayed on screen if the user input is 2019 user_num7 = input() user_num7 = int(user_num7) if user_num7 == 2001: print(user_num7,': Twin Towers') elif user_num7 == 2008: print(user_num7,': Great Recession') elif user_num7 == 2017: print(user_num7,': Hurricane Maria') else: print('No Disasters!') A. Great Recession B. Twin Towers C. No Disasters! D. None of the options listed E. Hurricane Maria

C. No Disasters!

What will be displayed on screen when all the following statements have been executed (assume the user enters 22)? age = input('What is your age?') age = print(age) A. age = 22 B. What is your age? C. What is your age? 22 D. 22

C. What is your age? 22

What will be displayed on screen when the following statement is executed? greeting = input('What would you like to say?') A. blinking error B. "What would you like to say?" C. What would you like to say? D. greeting

C. What would you like to say?

Given the following code: cheer = "Go Warriors!" for cheerl in cheer: print(cheerl) for cheerr in reversed(cheer): print(cheerr) print("The entered cheer was:",cheer) What is the loop variable for the reversed cheer? A. cheer B. None of the options listed C. cheerr D. cheerl

C. cheerr

If the following code is saved as drawing.py, how would one add these two functions to another program without cutting and pasting the two functions? cr = '#' def draw_square(size): for h in range(size): for w in range(size): print(cr, end='') print() def draw_rect(height, width): for h in range(height): for w in range(width): print(cr, end='') print() A. import draw_square B. draw_rect(12,5) C. import drawing D. draw_square(3)

C. import drawing

Which line is not part of the loop body? answer = 'y' while answer != 'n': s = input("Song?") print(s) answer = input("Continue (y/n)?") print("Thank you for playing") A. answer = input("Continue (y/n)?") B. print(s) C. print("Thank you for playing") D. s = input("Song?")

C. print("Thank you for playing")

What informs the programmer that the interpreter is ready to accept commands. A. code B. line C. prompt D. interpreter

C. prompt

What code may be used to display the Names column of the dataframe created with the following code? import pandas studentsdf=pandas.read_csv("student.csv") A. print("Studentsdf.Names") B. print(Names) C. studentsdf.Names D. studentsdf.Names.print

C. studentsdf.Names

which symbol is used to delineate docstrings for comments in code? A. three consecutive + B. three consecutive $ C. three consecutive " D. none of the options listed

C. three consecutive "

What will be displayed on screen if the user input is 2008 user_num7 = input() user_num7 = int(user_num7) if user_num7 == 2001: print(user_num7,': Twin Towers') elif user_num7 == 2008: print(user_num7,': Great Recession') elif user_num7 == 2017: print(user_num7,': Hurricane Maria') else: print('No Disasters!') A. No Disasters! B. 2017: Hurricane Maria C. 2001: Twin Towers D. 2008: Great Recession

D. 2008: Great Recession

What will be displayed on screen if the user input is 1990 user_entry = input() user_entry = int(user_entry) if user_entry >= 1996: print('GenZ') elif user_entry >= 1979: print('GenY') elif user_entry >= 1964: print('GenX') else: print('Baby boomer or older') A. GenX B. Baby boomer or older C. GenZ D. GenY

D. GenY

What will be displayed on screen if the user input is 2000 user_entry = input() user_entry = int(user_entry) if user_entry >= 1996: print('GenZ') elif user_entry >= 1979: print('GenY') elif user_entry >= 1964: print('GenX') else: print('Baby boomer or older') A. GenY B. GenX C. Baby Boomer or older D. GenZ

D. GenZ

What will be assigned to bookstring when the user enters the following in sequence in response to the question Book? Milkman Improvement March iterateb = input("How many books? ") iterateb = int(iterateb) bookstring = ' ' for i in range(iterateb): booktitle = input("Book? ") bookstring = bookstring + ' ' + booktitle print("The books on your list are:"+bookstring) A. Milkman booktitle booktitle B. bookstring booktitle booktitle C. March D. Milkman Improvement March

D. Milkman Improvement March

What will be displayed on screen after the following statement executes, given that total_grade = '88'? print('Your final grade is '+total_grade+' out of 100 possible points') A. Your final grade is88out of 100 possible points B. Your final grade is '88' out of 100 possible points C. Your final grade is 'total_grade' out of 100 possible points D. Your final grade is 88 out of 100 possible points

D. Your final grade is 88 out of 100 possible points

which is the following is a valid assignment statement? A. 2019_price = 50.0 B. 2019Price_= 50.0 C. 2019price = 50.0 D. a2019price = 50.0

D. a2019price = 50.0

How would one sort the Tops column of a dataframe named clothesdf in ascending order using pandas? A. clothesdf.sort_values("tops",ascending=True) B. clothesdf.sort_values("Tops",ascending=true) C. Tops.sort_values("clothesdf",ascending=True) D. clothesdf.sort_values("Tops",ascending=True)

D. clothesdf.sort_values("Tops",ascending=True)

What is the data type of the value assigned to the name age after all the following statements have executed? age = 15 age += 2 age = float(age) sfloat = str(age) A. integer B. string C. tuple D. float

D. float

Given the following code: iteratem = input("How many movies? ") iteratem = int(iteratem) moviestring = ' ' for i in range(iteratem): movietitle = input("Movie? ") moviestring = moviestring + ' ' + movietitle print("The movies on your list are:"+moviestring) Which variable determines the number of times that the loop iterates? A. moviestring B. i C. movietitle D. iteratem

D. iteratem

Which range function will generate the sequence of even numbers from 10 to 1000? A. range(8,1002,2) B. range(8,1000,2) C. range(10,1000,2) D. range(10,1002,2)

D. range(10,1002,2)

T or F: Avoiding redundancy means to avoid calling a function from multiple places in a program

False


Set pelajaran terkait

Abdomen: Peritoneum and Peritoneal cavity

View Set

Instrument Rating Knowledge Exam

View Set

Old Testament Exam 1 Springer Study Guide

View Set

Romantic Period and Restoration Period

View Set

Assignment: Exercise 3.1 (Practice)

View Set