1/36
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
input() Rule
Whatever the use types (even numbers) will be captured as a string
Int()
Converts strings into integers (Ex. “20” becomes 20)
Float()
keeps the decimal
What happens when you you run int(“3.85”)?
The decimal will be dropped completely, does not round
What does print() do automatically?
Adds a newline character at the end
What does \” and \’ do?
Adds quotes inside print statement, or statement that already has quotes
is _score = 10 legal or illegal?
legal
is this legal or illegal? 1_place = 2
illegal
What is a single =?
assignment operator
What is a double =?
true/false statement
What is the execution rule?
Calculates RIGHT side first and stores it to the variable on the LEFT
What returns floats?
/, math.sqrt, math.pow
What returns integers (no decimal)?
floor, modulo, math.ceil, math.floor
Order of operations
Parentheses, exponents, multiplication, addition
what is x += 5
x = x + 5
What is x *= 2
x = x * 2
What is x %= 4
x = x % 4
What does random.randint include?
Both start and stop
what does random.randrange include?
Start but not stop
What is random()
float between 0 and 1
What is random.uniform?
Gives decimal values between the ranges
What two math symbols do strings work with?
+(join) and *(repeat)
What does print(len(“hello!”)) do?
output: 6 (counts amount of characters)
What does print (python[0]) do?
output: p (prints the first character of the word)
What do you need to be aware of when using math.sqrt and math.pow?
They always return floats, even if the result is a whole number
What is a explicit conversation?
Manually using int(), float(), or str()
Syntax Error
Violates python grammar rules before running
Runtime error
occurs while the program is running (Ex. dividing by 0)
indentation error
lines arent being properly indented
value error
invalid value is used (ex. using letters in int())
name error
trying to use a variable that does not exist
type error
When performing an operation on a data type that doesn’t support it (Ex. 5 + “apples”)
Logic errors
program runs properly but the output is incorrect due to human error
math.ceil
rounds UP to nearest integer
math.floor
rounds down is nearest integer
math.pow
puts x to the power of y (x,y) (ex. (2, 3) = 8)
math.fabs
absolute value