Intro to Python

Ace your homework & exams now with Quizwiz!

What Will Be The Output Of The Following Code Snippet? class Sales: def __init__(self, id): self.id = id id = 100 val = Sales(123) print (val.id)

123

Select the output produced by the script x = 6 y = 1 print(x ** y)

6

temp = 10 def convert_temp(x): """Converts the temperature from Celsius to Fahrenheit""" global temp temp = (x * 1.8) + 32 convert_temp(temp) print(temp) A. 50.0 B. 10 C. 50 D. 10.0

A. 50.0

Which Of The Following Represents A Template, Blueprint, Or Contract That Defines Objects Of The Same Type? A. A class B. An object C. A method D. An EC2 instance

A. A class

What Will Be The Output Of The Following? s = "\t\tWelcome\n" print(s.strip()) A. Welcome B. \t\tWelcome\n C. \t\tWelcome D. Welcome\n

A. Welcome

Complete the script by choosing the best answer to fill in the blank __ to produce the output shown OUTPUT [7, 4, 3] SCRIPT x = ['X', 7, 'Y', 4, 3, 'Z'] integers = [j for j in x __ type(j) == int] print(integers) A. if B. when C. such that D. is.my

A. if

Write a for loop that goes through each sublist of house and prints out the x is y sqm, where x is the name of the room and y is the area of the room. The code is below, choose the correct response to fill in the blank: # house list of lists house = [["hallway", 11.25], ["kitchen", 18.0], ["living room", 20.0], ["bedroom", 10.75], ["bathroom", 9.50]] # Build a for loop from scratch for sublist in house : print("the " + str(_________ + " is " + str(sublist[1]) + " sqm")) A. sublist[0] B. x C. sublist[2] D. house[0]

A. sublist[0]

Given an integer count of a number of donuts, return a string of the form 'Number of donuts: <count>', where <count> is the number passed in, and, if the count is 10 or more, then uses the word 'many' instead of the actual count. So donuts(5) returns 'Number of donuts: 5' and donuts(23) returns 'Number of donuts: many' True or False, the following Python code is the solution: def donuts(count): if count < 10: return 'Number of donuts: ' + str(count) else: return 'Number of donuts: many'

True

When you launch an instance, you must select an AMI that's in the same region.

True

Complete the script by filling in the blank to produce the output shown OUTPUT [9, 4, 16, 36] SCRIPT x = [3, 2, 4, 6] squares = [ i ** 2 for i in __ ] print(squares)

x


Related study sets

renal part 2 (fluid and e- changes) - exam 3

View Set

PrepU Chp 28: Assessment of Hematologic Function and Treatment Modalities

View Set

Exam #3 - Fundamentals - 4/10/20

View Set