What is the operator for exponentiation (raising a number to a power) in Python?
**
What is the built-in function to find the absolute value of a number?
abs()
What built-in function rounds a number to the nearest integer? (It rounds halves to the nearest even number in Python 3, but this can be complex to test for flashcards.)
round()
What is the operator for integer division (the result is the integer part of the quotient) in Python?
//
What is the operator for the modulo operation (finding the remainder of a division) in Python?
%
What Python math module function returns the square root of a number?
math.sqrt(x)
What Python math module function returns the value of $\pi$ (pi)?
math.pi
What Python math module function returns $e^x$ (e raised to the power of x)?
math.exp(x)
What Python math module function returns the natural logarithm of a number x (log base $e$)?
math.log(x)
What Python math module function returns the largest integer less than or equal to x (floor function)?
math.floor(x)
What Python math module function returns the smallest integer greater than or equal to x (ceiling function)?
math.ceil(x)
What is required to use functions like sqrt or pi in Python?
import math (or from math import function)
What is the definition of a prime number?
A natural number greater than 1 that has no positive divisors other than 1 and itself.
Are the numbers 0 and 1 considered prime?
No, they are not prime.
What is the smallest prime number?
What is the basic logic to test if a number ‘n’ > 2 is prime?
Loop from 2 up to n-1 and check if ‘n’ is divisible by any number in that range.
What operator checks if ‘n’ is perfectly divisible by ‘i’ in Python?
The modulo operator: n % i == 0
What is the key optimization for a primality test loop for a number ‘n’?
You only need to check for divisors from 2 up to the square root of ‘n’.
What Python ‘math’ module function helps implement the square root optimization?
math.sqrt(n)