coding

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

What is the character that in-line Python comments begin with? 1)# 2)% 3)- 4)"

1

What does the following code print? x = 3.4 y = 1 print int(x) print x + y 1)3.4 4.4 2)3 4.4 3)3 4 4)The code causes an error

2

What is the final result of the expression 7 / 3 + 6? 1)0 2)8.33333333333 3)8 4)0.777777777778

3

What kind of data does a float variable contain? 1)Whole numbers 2)Words 3)Numbers that can have decimal components 4)A float is not a Python variable type

3

Suppose you have a variable defined a = "4". What is the variable type of a? 1)str 2)int 3)float 4)number

1

What does the following program print? a = "hi" b = 4 c = a * b print type(c) 1)<type 'str'> 2)<type 'int'> 3)<type 'float'> 4)The program crashes and doesn't print anything

1

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? 1)user_age 2)uSeRaGe 3)user!age! 4)1user_age

1

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

2

What is the final result of the expression 2**3? 1)6 2)8 3)2 4)That is not a valid Python expression.

2

Which one of the statements below will cause an error? 1)ans = "hi" * 8 2)ans = "hi" + 9 3)ans = "hi" + "hi" + "hi" 4)ans = ("a" * 4) + "b"

2

Choose the correct declaration of a float variable with the value 3.14. 1)pi = "3.14" 2)pi = int(3.14) 3)pi = 3.14 4)float pi = 3.14

3

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? ") 1)A, B, C, D 2)B, C, A, D 3)A, C, D, B 4)C, B, A, D

3

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

3

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 1)Fernandez Florence 2)Florence Fernandez 3)FlorenceFernandez 4)Florence Fernandez

3

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. 1)I, IV 2)II, III 3)I, II, IV 4)I, III, IV

3

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

4

Choose the print statement below that will cause an error. Assume that num has the value 6, and name has the value Isabella. 1)print name + ":" print num 2)print name + " wants " + "num " + "candies" 3)print name + ": " + str(num) 4)print name + ": " + num

4

What is the final result of the expression 4 + 5 * 3? 1)27 2)12 3)21 4)19

4

Which of the following choices is NOT a Python variable type? 1)int 2)str 3)float 4)number

4

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? 1)num = str(input("Enter a number: ")) 2)num = number(input("Enter a number: ")) 3)num = input("Enter a number: ") 4)num = int(input("Enter a number: "))

4


Set pelajaran terkait

Ch 4 pt5 Variable Life Insurance Products

View Set

Chapter 1: The Investment Setting

View Set

Toxicity 5: Factors Affecting Toxicity

View Set