Built-in Functions and Lambdas Flashcards
7 cards from real HACKERRANK practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 7 Built-in Functions and Lambdas flashcards as text
What does `all([True, True, True])` return?
Answer: True
all() returns True only when every element in the iterable is truthy.
What is the result of `round(3.14159, 2)`?
Answer: 3.14
round() with ndigits=2 rounds the float to 2 decimal places, giving 3.14.
What does `enumerate(['a', 'b', 'c'], start=1)` produce?
Answer: (1,'a'), (2,'b'), (3,'c')
enumerate with start=1 pairs each element with an index beginning at 1 instead of 0.
What is the output of `list(zip([1,2,3], ['a','b','c']))`?
Answer: [(1,'a'), (2,'b'), (3,'c')]
zip pairs elements from each iterable at the same index into tuples.
Which built-in function converts a string to an integer?
Answer: int()
int() converts a string (or other numeric type) to an integer.
What does `sum([1, 2, 3], 10)` return?
Answer: 16
sum() accepts an optional start argument; it adds 1+2+3+10 = 16.
What does `len({'a': 1, 'b': 2, 'c': 3})` return?
Answer: 3
len() on a dictionary returns the number of key-value pairs.