python building notes Flashcards

1
Q

isdigit()

A

method returns True if all the characters are digits, otherwise False.

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

any input default data type is

A

a string

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

how do you call a function

A

functionName()

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

how do you create a copy of list

A

newcopylistname = listtocopy[:]

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

if you don’t need the variable but simple in the for loops what do you use in place of a variable name

A

__ underscore

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

when using f-strings, the data type of the variable does not need to be changed to a string. Python handles the conversion for you. (True or False)

A

True

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

can you get an input and directly lower it in the input() section only

A

yes, just add .lower() after asking the input

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

how to have it count backwards from 5 to 1 using a for

A

for num in range(5, 0, -1):

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

How to get a random integer number

A

randint (don’t forget to import it)

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

how to make things happen for certain number of times

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

how to get random things of specific value in a list with dictionaries

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

using if how would you Check if the function returns a value

A

if objectname.methodname():

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

calling a function with return won’t directly print anything. You need to either use ___ on the returned value or store it in a variable for further use

A

print statement

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

how to check if the first letter and the last letter of the string is the same

A

string[0] == string[-1]

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

can you add a f string to a return statement

A

yes! return f”Hello, {name}!”

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

how would you iterate through each word in the input list ‘words’

A

using the “for” loop

17
Q
A