Math + Code Quiz Flashcards

View the flashcards tags for a the code.

What is the equation for the sum of the first n natural numbers?

The sum of the first n natural numbers is given by the formula:

i=1ni=n(n+1)2

What does the Pythagorean theorem state?
For a right triangle with legs a and b and hypotenuse c:

a2+b2=c2

What is the derivative of ex?

ddxex=ex

The exponential function is its own derivative.

What does this Python expression return?

[x**2 for x in range(5)]
[0, 1, 4, 9, 16]

A list comprehension that squares each number from 0 to 4.

What is the output of this Python code?

d = {"a": 1, "b": 2}
print(d.get("c", 0))
0

dict.get(key, default) returns the default value when the key is missing instead of raising a KeyError.

What is Euler's identity?

eiπ+1=0

It connects five fundamental constants: e, i, π, 1, and 0.

How do you reverse a list in Python in place?

nums = [1, 2, 3, 4, 5]
nums.reverse()
# nums is now [5, 4, 3, 2, 1]

list.reverse() mutates the list and returns None.

What is the quadratic formula?

For ax2+bx+c=0:

x=b±b24ac2a

What does zip do in Python?

list(zip([1,2,3], ["a","b","c"]))
[(1, 'a'), (2, 'b'), (3, 'c')]

zip pairs elements from multiple iterables by index.

What does a binary tree traversal look like?

Root Left Right L-Left L-Right R-Left R-Right

In-order: D, B, E, A, F, C, G

--- Back to demos