quiz Flashcards

(12 cards)

1
Q

whats output of: type(“5”)

A

str

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

whats output of (“Moon\n Light”)

A

Moon
Light

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

what is % used for

A

modulo, so 10%3 = 1, bcuz 10/3 leaves a REMAINDER of 1

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

what is // used for

A

discards the remainder, so 7//2 = 3

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

what is # used for

A

thats for a comment

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

whats the output of “2” + “2”

A

“22”, cuz it puts both strings together

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

whats the output of the following code:

y = 0
print (f’ They have {y} interest in my story!’)

A

They have 0 interest in my story!

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

whats the output of this:

x=2
y=3
y= x
x=0
y

A

answer is 2, always go back to the top

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

whats the output of this

for i in range (3):
s = 2
s = s + i
print (s)

A

answer is 4, ohh cuz when its a for loop, so when the loop is done (starts with 0, then 1, then 2 cuz range of 3), when its done the last value of i is 2, soooo i = 2

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

whats the output of this code

for i in range (1,4,4):
print (i)

a
1
2
3

b
1
4
4

c
1
3

d
1

A

d! = 1

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

wats the output of

def g(x):
print (2*x)
g(4)

A

8

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

whats output of
2*2//3+1

A

2

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