CodeHS Unit 3-Python

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

C

Choose the correct declaration of a float variable with the value 3.14. A. pi = "3.14" B. pi = int(3.14) C. pi = 3.14 D. float pi = 3.14

D

Choose the option that correctly prints out the variable(s). A. x = "codehs" print int(x) B. num = 8 print "num" C. name = "Alyx" age = 32 print name + "is " + age D. language = "Python" print "I'm learning " + language

A

What is the character that in-line Python comments begin with? A. # B. % C. - D. "

D

What is the final result of the expression 4 + 5 * 3? A. 27 B. 12 C. 21 D. 19

C

In what order should these statements be executed in order to get input from the user and print out the result? A) response = input("Do you like cheese? ") B) print "You have chosen " + confirm C) print "You responded " + response D) confirm = input("Are you sure? ") A. A, B, C, D B. B, C, A, D C. A, C, D, B D. C, B, A, D

B

On which line of code will Python error? weight = input("How much do you weigh? ") oz_water = weight / 2 print "You should drink " + str(oz_water) print "ounces of water every day if you weigh " + weight A. Line 1 B. Line 2 C. Line 3 D. Line 4

A

Suppose you have a variable defined a = "4". What is the variable type of a? A. str B. int C. float D. number

A

Suppose you run the following Python program: x = input("Enter some text: ") print x While the program is running, after the prompt has been printed, the user types the following and presses Enter: Delaware ratified the U.S. Constitution in 1787. What does the program print? A. Delaware ratified the U.S. Constitution in 1787. B. Delaware ratified the U.S. Constitution in C. Delaware D. (The program does not print anything.)

A

What does the following Python code display? print "Hello" print "World" A. Hello World B. HelloWorld C. Hello World D. Hello World

C

What is the output of the following program? Assume the user enters "Florence", then "Fernandez". first_name = input("What is your first name? ") last_name = input("What is your last name? ") whole_name = first_name + last_name print whole_name A. Fernandez Florence B. Florence Fernandez C. FlorenceFernandez D. Florence Fernandez

A

What is the type of the variable x in the following Python program? x = input("Enter something: ") A. string B. integer C. float D. The type cannot be determined.

C

What kind of data does a float variable contain? A. Whole numbers B. Words C. Numbers that can have decimal components D. A float is not a Python variable type

D

What type is the following variable? x = "Hi there" A. float B. integer C. boolean D. string

B

Which Python code segment will display "Hello, world!" on the screen? A. display Hello, world! B. print "Hello, world!" C. print Hello, world! D. "Hello, world!"

B

Which of the following Python programs will not run? A. x = 4 y = 5 print x + y B. x = 4 y = "hi" print x + y C. x = 4 y = 5.5 print x + y D. x = 4 print x + 5

B

Which of the following best describes the main purpose of comments? A. Comments create better spacing in programs. B. Comments describe your program so other people can read it more easily. C. Comments warn the people running the program about potential problems with the program.

D

Which of the following choices is NOT a Python variable type? A. int B. str C. float D. number

C

Which of the following is NOT a program that will produce the following output? hellohellohello A. var = "hello" * 3 print var B. var = "hello" + "hello" + "hello" print var C. var = "hello" print var print var print var D. In the following code, assume the user enters 3. num_times = int(input("How many times?: ")) var = "hello" * num_times print var

A

Which of the following is NOT a valid type of comment in Python? A. %% This is a comment B. # This is a comment C. """ This is a comment """

A

Which of the following operations will output a value of 5? A. 11/2 B. 11.0/2 C. float(11)/2 D. 2 + 3 * 2

D

Which of the following options is the best way to get a number from the user that you plan to use in a mathematical equation? A. num = str(input("Enter a number: ")) B. num = number(input("Enter a number: ")) C. num = input("Enter a number: ") D. num = int(input("Enter a number: "))

C

Which of the following statements is true about print statements? I. In order to print a string literal, the string must be enclosed in quotes. II. Each print statement will be printed on its own line. III. Print statements will not let you print strings and numbers in the same statement. IV. Print statements are how you display text on the screen. A. I, IV B. II, III C. I, II, IV D. I, III, IV

D

Choose the print statement below that will cause an error. Assume that num has the value 6, and name has the value Isabella. A. print name + ":" print num B. print name + " wants " + "num " + "candies" C. print name + ": " + str(num) D. print name + ": " + num

C

What does the following Python program print? x = "I am" y = 6 z = "feet tall" print x print y print z A. I am 6 feet tall B. I am6feet tall C. I am 6 feet tall D. x y z

B

What does the following Python program print? x = 9 + 6 / 3 * 2 - 1 print x A. 9 B. 12 C. 15 D. 21

B

What does the following code print? x = 3.4 y = 1 print int(x) print x + y A. 3.4 4.4 B. 3 4.4 C. 3 4 D. The code causes an error

A

What does the following program print? a = "hi" b = 4 c = a * b print type(c) A. <type 'str'> B. <type 'int'> C. <type 'float'> D. The program crashes and doesn't print anything.

C

What is the difference between a binary operator and a unary operator? A. A computer can use binary operators, but it cannot use unary operators. B. A unary operator needs two things, while a binary operator only needs one. C. A binary operator needs two things, while a unary operator only needs one. D. Binary operators are used for arithmetic expressions, while unary operators are for strings.

B

What is the final result of the expression 2**3? A. 6 B. 8 C. 2 D. That is not a valid Python expression.

C

What is the final result of the expression 7 / 3 + 6? A. 0 B. 8.33333333333 C. 8 D. 0.777777777778

A

Which of the following choices is a properly formed Python variable name, meaning it is both legal in the Python language and considered good style? A. user_age B. uSeRaGe C. user!age! D. 1user_age

B

Which one of the statements below will cause an error? A. ans = "hi" * 8 B. ans = "hi" + 9 C. ans = "hi" + "hi" + "hi" D. ans = ("a" * 4) + "b"


संबंधित स्टडी सेट्स

Arizona Life Insurance Exam - Life Insurance Policy Provisions, Options, and Riders

View Set

N CLEX Medical Surgical:Genitourinary Disorders

View Set

Art Appreciation Exam 3 CH. (15-17, 20)

View Set

Human Growth and development module 2 questions

View Set

Medication and IV administration

View Set

American Public Policy short answers

View Set

Intro to Digital Forensics Chapter 9 Review Questions

View Set