EXTRAS FROM QUIZ QUESTIONS Flashcards

1
Q

when does a result or print return something with quotation marks?

A

returns quotation marks ONLY for strings, and prints NEVER return with quotations unless directly after a \

OR if you use
repr(string) in the print

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

what does
x = ‘hello world’
repr(x)
do?

A

’ ‘hello world’ ‘
^two quotation marks on each side, jupyter notebooks makes it a string and repr makes it also

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

will this compile?
str = ‘cat’
str[0] = ‘dog’

A

no, as you are editing the string on a character basis. you COULD change the string as a whole, like:
str = str + ‘dog’
but you cant edit the string itself (immutable)

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

what does repr do?

A

keeps/returns the string surrounded by single quotation marks

print(repr(“bill”))
prints
‘bill’

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

what does end=’…’, sep=’ ‘ mean?

A

instead of printing a new line, the end of the print will be a …, and the sep means when youre printing multiple things it is separated by the specific thing = to set

ex.

print(‘bruh’, ‘i’, ‘cant’, end = ‘…’, sep=’bill’)
would print

bruhbillibillcantbill…

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

what does .title() do?

A

capitalizes first letter and lowercases other letters of each word separated by a space

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

how to capitalize m in mark?

A

‘mark’.title()

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

what does the floor function do?

A

MATH MODULE FUNCTION

returns a float lowered to the nearest whole number (-3.5——>-4.0, 3.5—->3.0)

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

true/false: input statements from users are printed IMMEDIATELZY AFTER the input prompt, with no spaces automatically added

A

true true true

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

make a condition that returns false when a string does NOT equal another string

A

if not(x == y):

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

does != work on python?

A

yes, but the other stuff from java like && || just straight dont work.

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

is round part of the math class?

A

nah

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

what will this print:
i = 1
if i ==1, 2, 3:
print(“YES”)

A

error, you cant do equals like that, must put “i == 1 or i == 2 or i ==3”

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