EXAM Flashcards

1
Q

result?
4e2.is_integer()

A

True, its a conceptual integer even if it has a decimal point. i guess.

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

what is printed:

print(round(4.05, 1))
print(round(4.15, 1))
print(round(4.25, 1))
print(round(4.35, 1))
print(round(4.45, 1))
print(round(4.55, 1))
print(round(4.65, 1))
print(round(4.75, 1))
print(round(4.85, 1))
print(round(4.95, 1))
print(round(5.05, 1))
print()
print(round(5.05, 1))
print(round(5.15, 1))
print(round(5.25, 1))
print(round(5.35, 1))
print(round(5.45, 1))
print(round(5.55, 1))
print(round(5.65, 1))
print(round(5.75, 1))
print(round(5.85, 1))
print(round(5.95, 1))
print(round(6.05, 1))
print()
print(round(243, -2))

A

4.0
4.2
4.2
4.3
4.5
4.5
4.7
4.8
4.8
5.0
5.0

5.0
5.2
5.2
5.3
5.5
5.5
5.7
5.8
5.8
6.0
6.0

200

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

9/36?

A

4.0

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

what does this print:

x = 125.5
y = 124.5

print(f”rounded x is {x:.0f}, and rounded y is {y:.0f}”)

A

rounded x is 126, and rounded y is 124

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

[] vs. ()

A

[] for indices, () for functions like len(x)

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

what will this return:

print(4*“a”)

A

aaaa

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

can you use ! in python?

A

only in !=

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

what class is abs() in python?

A

none

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

difference between formatted string s or d and simply doing formatted {x}?

A

none, the d and s specifiers dont really do anything

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

what does this print?
x = 1234

print(f”hello” + str(x))

A

hello1234

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

what will this print?

x = 1234

print(f”hello {x:s}”)

A

ERROR

because s is a string specifier, does not work on ints

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