Unit 3 Flashcards

1
Q

What is the final result of the expression 4 + 5 * 3?

A

19

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the final result of the expression 7 / 2 + 6?

A

9.5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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 + “: “ + num)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which one of the statements below will cause an error?

A

ans = “hi” + 9

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does the following program print?

A

<type ‘str’>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Suppose you have a variable defined a = “4”. What is the variable type of a?

A

str

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Choose the option that correctly prints out the variable(s).

A

language = “Python”
print(“I’m learning “ + language)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What kind of data does a float variable contain?

A

Numbers that can have decimal components

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

x = 3.4
y = 1
print(int(x))
print(x + y)

A

3
4.4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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 = int(input(“Enter a number: “))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the final result of the expression 2**3?

A

8

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the character that in-line Python comments begin with?

A

#

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the difference between a binary operator and a unary operator?

A

A binary operator needs two things, while a unary operator only needs one.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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, C, D, B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

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

FlorenceFernandez

17
Q

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 string and number characters in the same statement.
IV. Print statements are how you display text on the screen.

A

I, II, IV

18
Q

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

19
Q

Which of the following choices is NOT a Python variable type?

A

number

20
Q

Choose the correct declaration of a float variable with the value 3.14.

A

pi = 3.14