3. Python Advanced Flashcards
What does the built-in function “len()” do?
Returns the number of items in an object.
What does “type()” return?
The type of an object.
What does “range()” do?
Generates a sequence of numbers.
What does “input()” do?
Gets input from the user as a string.
What does “int()” do?
Converts a value to an integer.
What does “str()” do?
Converts a value to a string.
What does “float()” do?
Converts a value to a float.
What does “bool()” do?
Converts a value to a Boolean.
What does “sum()” do?
Returns the sum of all items in an iterable.
What does “sorted()” do?
Returns a sorted version of an iterable.
What does “enumerate()” do?
Adds a counter to an iterable.
What does “zip()” do?
Combines multiple iterables element-wise.
What does “str.lower()” do?
Returns the string in lowercase.
What does “str.strip()” do?
Removes leading and trailing whitespace.
What does “str.split()” do?
Splits a string into a list.
What does “str.join()” do?
Joins list elements into a string.
What does “str.replace()” do?
Replaces parts of a string.
What does “list.append()” do?
Adds an item to the end of the list.
What does “list.pop()” do?
Removes and returns the last item.
What does “dict.get()” do?
Returns the value for a key, or default if key is not found.
What does “dict.items()” do?
Returns key-value pairs in a dictionary.
What causes an IndentationError?
Incorrect or inconsistent indentation.
What causes a SyntaxError?
Invalid Python code structure.
What causes a NameError?
Using a variable that hasn’t been defined.