Quiz 2 Flashcards
(42 cards)
What is an f-string? and what’s it used for?
Formatted string literal - used to format output of expressions
What is a statement
programming instruction
What is an expression
Code that returns a value (eg. calculations)
What is an assignment
A new variable is assigned
What is a string literal
Text enclosed in quotations
What does an object represent
A value (eg. in x=4, 4 is automatically created as an object)
What does immutable mean? What is mutability?
Immutable means it can’t be changed. Mutability is on object’s ability to be changed.
Which data types are mutable
Which data types are immutable
strings and integers
What is a literal?
A specific value
What is a logical operator/boolean logic?
Treats operands as True or False (for example, x>4 -> True).
What are the three examples of logical operands?
And, or, not
What is a while loop (difference between that and a for loop?)
Loop that goes until we reach a condition
NEED TO ADD AN ITERATOR (i-0)
Could continue forever (for loop has a range)
What is a for loop (difference between that and a while loop?)
Loop that has an end
Automatically puts in the iterator
Has a range (while loop could continue forever)
what is a modulus (example)
%
division with a remainder
ex: 7%2 = 1
== vs =
== - checking IF something is true (x==5, does x equal 5?)
= - this IS true (ex: x=5)
What is a value?
Content being stored (types: strings, integers…)
What is a float
decimal
What is an integer?
whole number
What does // do?
how many times the divider can fit in
ex: 5//2 = 2
2 can fit in 5 twice
What is pseudocode
Explanation in sentences
Do you need to add an iterator for a for loop?
No! (automatically knows)
what happens if we had a break into the loop?
It skips the else statement
What does n += 1 mean?
n = n + 1