python building notes Flashcards
isdigit()
method returns True if all the characters are digits, otherwise False.
any input default data type is
a string
how do you call a function
functionName()
how do you create a copy of list
newcopylistname = listtocopy[:]
if you don’t need the variable but simple in the for loops what do you use in place of a variable name
__ underscore
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)
True
can you get an input and directly lower it in the input() section only
yes, just add .lower() after asking the input
how to have it count backwards from 5 to 1 using a for
for num in range(5, 0, -1):
How to get a random integer number
randint (don’t forget to import it)
how to make things happen for certain number of times
how to get random things of specific value in a list with dictionaries
using if how would you Check if the function returns a value
if objectname.methodname():
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
print statement
how to check if the first letter and the last letter of the string is the same
string[0] == string[-1]
can you add a f string to a return statement
yes! return f”Hello, {name}!”