Python Programming Honors Review

¡Supera tus tareas y exámenes ahora con Quizwiz!

name = "skye homsi" name1 = name.title()name2 = name_1.swapcase()print(name2) What is the output from the above code? a. "Skye Homsi" b. "SKYE HOMSI" c. "skye homsi" d. "sKYE hOMSI"

d. "sKYE hOMSI"

Which code formats the string "Green" to "GREEN"? a. .isupper() b. .capitalize() c. .istitle() d. .upper()

d. .upper()

True or False: The type() function is used to change from one data type to another.

False

What does type(1024) return? a. all of the below b. str c. float d. int

d. Int

What does type("Hello World!") return? a. all of the below b. int c. float d. str

d. Str

def showName():print("Tobias Ledford") Which code calls the function in the above code? a. showName.run() b. open(showName) c. run showName d. showName()

d. showName()

Which is a valid Python code comment? a. # use comments to describe the function of code. b. /comment warnings can be placed in comments. c. comments make code easier to update. d. 'comment comments can provide use instructions for other developers.

a. # use comments to describe the function of code.

What does type(3.55) return? a. float b. int c. str d. all of the above

a. Float

Which version of Python does this course cover? a. Pyhton 5 b. Python 4 c. Python 3 d. Python 2

c. Python 3

print("It's time to code") What is the output of the above code? a. It's time to code b. It"s time to code c. Its time to code d. an error

a. It's time to code

answer = input("enter your answer: ") print("You entered " + answer) If user input is 38, what is the output of the above code? a. TypeError b. Syntax Error c. You entered 38 d. You entered enter your answer

c. You entered 38

Which is an example of the proper use of the Python input() function? a. answer = input(enter your answer: ) b. answer = INPUT(enter your answer: ) c. answer = input("enter your answer: ") d. answer = INPUT("enter your answer: ")

c. answer = input("enter your answer: ")

def addNum(num1 = 10):print(num1 + num1) Choose the correct output of calling the above function using the following code: a. addNum() b. 0 c. 10 d. 20 c. An Error

d. 20

True of False: The string method .swapcase() converts from string to integer.

False

True or False: Python cannot display quotes in strings using print().

False

True or False: The code: print("I am", 17, "years old") will output: I am17years old

False

True or False: "Hello, world!" is a specialized program used specifically for Python.

False

True or False: In Python, strings can contain only letters a-z and A-Z.

False

True or False: In Python, we can use the "+" operator to add numbers, but not to add strings.

False

True or False: The input() function in Python returns user input as a string.

True

Which is a properly formatted Python print() function example? a. print("Welcome the", 3, New students!) b. print("Welcome the", 3 + New students!) c. print("Welcome the", 3, "New students!") d. print("Welcome the", 3 + " New students!")

c. print("Welcome the", 3, "New students!")

Print("Hello World!") will not output the message "Hello World!". What will it result in? a. TypeError b. SyntaxError c. NameError d. all of the above

c. NameError

How do you know if your code is correct and there are no errors? a. Read the code b. View the code c. Run the code d. Write the code

c. Run the code

What does the Python code: score = 3 + "45" result in? a. 48 b. 345 c. TypeError d. type()

c. TypeError

Choose the correct statement. a. Variables only represent strings in Python. b. The same variable in Python can be represented in either upper or lower case. c. Variables in Python can be initialized using the equals sign (=). d. New variables always start out as zero.

c. Variables in Python can be initialized using the equals sign (=).

length = "33" length.isalnum() What is the output of the above code? a. "33" b. Error c. False d. True

d. True

answer = input("enter your answer: ") print(10 + answer) If user input is 38, what is the output of the above code? a. 48 b. 1038 c. 10answer d. TypeError

d. TypeError

name = "SKYE HOMSI"print("y" in name.lower()) What is the output from the above code? a. True b. False c. "skye homsi" d. 3

a. True

Choose the correct statement. a. A variable name in Python cannot contain numbers. b. A variable value in Python cannot be updated. c. Variables are updated in Python using the keyword "new". d. Variable values in Python can change type, from integer to string

d. Variable values in Python can change type, from integer to string

Which contains only integers? (ignore the commas) a. Q, W, E, R, T, Y, a, s, d, f b. -2, -1, -0.5, 0, 0.5, 1, 2 c. 1, 2, 0, -3, 2, -5 d. 3, 2, 1, *, +, =, -

c. 1, 2, 0, -3, 2, -5

True or False: Function names cannot begin with a number as the first character.

True

True or False: Using comma separation, we can combine strings and numbers (int & float) in a single Python print() function without a TypeError.

True

"Hello".isalpha() What is the output of the above code? a. Hello b. True c. False d. Error

b. True

A function with 2 integer parameters could start with which definition? a. funct addNumbers(num1, num2): b. def addNumbers(num1, num2): c. def 2Numbers(num1, num2): d. FUNCTION addNumbers(x, y):

b. def addNumbers(num1, num2):

Which is an example of Python string addition that will run without error? a. newString = Hello + World! b. newString = "Hello " + "World!" c. newString = "Hello ' + "World!' d. all of the above

b. newString = "Hello " + "World!"

Given the code below and entering "Colette" for user_name input: python totalCost = 22.95userName = input("Enter your name: ") Choose the print statement that will output: Colette - the total is $ 22.95 for today's purchase a. print(Colette, "- the total is $", totalCost, "for today's purchase") b. print(userName, "- the total is $", totalCost, "for today's purchase") c. print(Colette, '- the total is $', totalCost, 'for todays purchase') d. print("userName", "- the total is $", "totalCost", "for today's purchase")

b. print(userName, "- the total is $", totalCost, "for today's purchase")


Conjuntos de estudio relacionados

Ch.7 Dramatic Structure Dramatic Characters

View Set

Fundamentals PrepU - Chapter 28: Pain Management

View Set

History 222 study guide John Wood Mr. Rodriguez

View Set

ECO CHAPTER 24 ( 61 - 95 ) END SEC02

View Set

Ch. 17 Somatic Symptom Disorders (3060 Exam 3)

View Set