Selection Flashcards
1
Q
What is selection?
A
Making choices in the flow of execution of a program made on the basis of expressions that must evaluate to true or false(Boolean)
2
Q
Example:
If :
else:
A
Just an example ;)
3
Q
What are the Boolean operators?
A
And or Not
4
Q
Operator precedence
A
() = highest
**
* / // %
< <= >= > == !=
Not
And
Or = lowest
5
Q
De Morgan’s laws
A
Not (A or B) = Not A and Not B
Not (A and B) = Not A or Bot B
6
Q
What is a+= 3?
A
A = a + 3
7
Q
What does the eval function do?
A
Convert string into number
I.e eval(input(…..))
8
Q
How to: — Truncate the floating point number
— Round a number up
— Round a number down
— Round to the closest integer or floating point?
— Square Root
A
- int(x)
- math.ciel(x)
- math.floor(x)
- round(x, decimal places)
- math.sqrt(x)