Midterm 1
What is the value assigned to x after the following statements execute? y = 'SJSU is the best' x = y[-1] z = y[0] x = x + z 'ts' 'tS' 'St' 'SJ'
'tS'
What is the value assigned to x? x = 5 * (38 % 7 + 3) + 4**2 63 46 29 64
46
What is the value of x after all the following statements execute? x = [100,200,300,400] x.append(500) x = tuple(x) x = len(x) 5 4 The code will return an error 500
5
What is the value assigned to x? x = 5 * (38 % 7) + (3 + 4)**2 63 29 46 64
64
What is the value of x after all of the following statements execute? x = (10,20,30,40) y = list(x) y.pop(2) x = tuple(y) x = sum(x) 80 30 70 100
70
What is the value of x after the following statements execute? x = 88 y = str(88) x = y x = x+y 176 8888 The code will return an error 88
8888
What is relatively small, volatile storage with fastest access located on a processor chip. Cache Operating System RAM Disk
Cache
What is a program that executes computer code? Line Code Interpreter Prompt
Interpreter
What is volatile storage with faster access usually located off a processor chip? Operating System RAM Disk Cache
RAM
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) 22 What is your age? 22 age = 22 What is your age?
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?') greeting What would you like to say? 'What would you like to say?' blinking cursor
What would you like to say?
Does the following statement create an immutable data type? scores = ('love',15,30,40)
Yes
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') Your final grade is, total_grade, out of 100 possible points Your final grade is88out of 100 possible points Your final grade is 88 out of 100 possible points Your final grade is total_grade out of 100 possible points
Your final grade is 88 out of 100 possible points
What will be displayed on screen after the following statement executes, given that total_grade = 88? print('Your final grade is: '+str(total_grade)+'!') Your final grade is: 88 ! Your final grade is:88! Your final grade is: 88! Your final grade is: total_grade!
Your final grade is: 88!
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) float string integer tuple
float
Which statement below will print the following on screen and wait for user entry? What is the first item? print() input() print('What is the first item?') input('What is the first item?')
input('What is the first item?')
What datatype is created with the following statement? salaries = ['Joe','10000','James','12000'] list integer tuple string
list
What print statement will print the following on screen? Given that height = 60 weight = 120 bmi = 24.333333333333332 With a height of 60 and weight of 120 your BMI is 24.333333333333332 print("With a height of",height,"and weight of",weight,"your BMI is",bmi) print("With a height of"+height+"and weight of"+weight+"your BMI is",bmi) print("With a height of",60,"and a weight of",120,"your BMI is",24.333333333333332) print("With a height of",weight,"and weight of",height,"your BMI is",bmi)
print("With a height of",height,"and weight of",weight,"your BMI is",bmi)
What print statement will display the following on screen? Given the following data: itemQuantity = 5 itemName = Pineapple itemPrice = 1.0 5 units of Pineapple at the unit price of 1.0 = $ 5.0 print(itemQuantity,'units of', itemName, 'at the unit price of', itemPrice, '= ', (itemPrice*itemQuantity)) print(itemQuantity 'units of' itemName 'at the unit price of' itemPrice = $' (itemPrice*itemQuantity)) print(itemQuantity,'units of', itemName, 'at the unit price of', itemPrice, '= $', (itemPrice*itemQuantity)) print(itemQuantity,'units of', itemPrice, 'at the unit price of', itemQuantity, '=$ (itemPrice*itemQuantity))
print(itemQuantity,'units of', itemName, 'at the unit price of', itemPrice, '= $', (itemPrice*itemQuantity))
Given the following variable names assigned with the following values as written: year = 2019 movie = 'Green Book' What statement will print the following on screen? 2019 best movie Oscar winner is Green Book! print(str(year)+' '+'best movie Oscar winner is '+' '+movie+'!') print(year+' '+'best movie Oscar winner is '+movie+'!') print(str(year)+'best movie Oscar winner is '+movie+'!') print(str(year)+' '+'best movie Oscar winner is '+movie+'!')
print(str(year)+' '+'best movie Oscar winner is '+movie+'!')
What informs the programmer that the interpreter is ready to accept commands. prompt line code interpreter
prompt
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? replace spaces in variable names with underscores place parentheses around Time/4.184 change Calories to calories replace parentheses with square brackets
replace spaces in variable names with underscores
What data type is created with the following statement? z = '55' integer float string list
string
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) y = str(y) integer float list string
string
What is the data type of x when all the following statements have executed? x = 99 y = str(x) x = y integer float string list
string
What is the data type that results from the following statement? price = input('how much is that dog in the window? ') integer string list float
string
What is the data type created with the following statement? integers5=(100,99,34,45,66) list integer float tuple
tuple
The following is an example of what type of error? lyric = 99 + " bottles of pop on the wall" name error value error type error syntax error
type error