Save
...
1.0 Fundamentals of programming
1.1 Programming concepts
1.1.2 Operators
Save
Share
Learn
Content
Leaderboard
Share
Learn
Cards (43)
What are operators in programming?
Symbols that perform operations
Operators are symbols that perform specific operations on one or more values, known as
operands
Operators are essential for manipulating data and performing calculations in
programming
.
Match the operator type with its function:
Assignment ↔️ Assigns a value to a variable
Arithmetic ↔️ Performs mathematical operations
Comparison ↔️ Compares two values
Logical ↔️ Combines or negates boolean values
Give an example of an assignment operator in programming.
x
=
x =
x
=
5
5
5
Arithmetic operators perform mathematical operations such as addition, subtraction, and
multiplication
Arithmetic operators can perform exponentiation using the
∗
*
∗
∗
*
∗
symbol.
What is the function of a comparison operator?
Compares two values
The modulus operator
%
returns the remainder
What is the result of
4
∗
4 *
4
∗
∗
*
∗
3
3
3
?
64
64
64
What are operators in programming used for?
Manipulating data
Operators are symbols that perform specific operations on operands to produce a
result
What is the function of the assignment operator?
Assigns a value
Arithmetic operators include addition, subtraction, multiplication, division, modulus, and
exponentiation
.
Which arithmetic operator returns the remainder of a division?
%
The comparison operator
>
>
>
means greater
What is the result of True && False using the AND operator?
False
The OR operator returns True if at least one
operand
is True.
What does the += operator do?
Add and assign
Operators are symbols that perform specific operations on operands to produce a
result
Which arithmetic operator adds two values together?
+
+
+
Comparison operators return a boolean result (True or
False
).
What does the
<
<
<
comparison operator check?
Less than
The NOT operator negates a boolean value, changing True to
False
What does the
!
=
! =
!
=
comparison operator mean?
Not equal to
Comparison operators are used to create conditional
statements
What is the result of
True && False
using the AND logical operator?
False
The OR logical operator returns True if at least one
operand
is True.
The NOT logical operator negates the value of a boolean, so
!
T
r
u
e
!True
!
T
r
u
e
results in False
What does the
=
=
=
assignment operator do?
Assign a value
What does the
+
+
+
=
=
=
assignment operator do?
Add and assign
The
−
=
- =
−
=
assignment operator subtracts a value and assigns the result to the variable, for example, x - = 2</latex> decrements
x
x
x
by 2
What is the result of
5 & 3
using the bitwise AND operator?
1
The bitwise XOR operator
^
returns True only if the bits are different.
What is the result of
5
<
<
1
5 < < 1
5
<<
1
using the left shift operator?
10
The right shift operator
>
>
> >
>>
moves bits to the right
What does operator precedence determine in an expression?
Order of evaluation
Match the operator with its precedence and associativity:
∗
*
∗
∗
*
∗
↔️ High, Right-to-left
∗
*
∗
,
/
/
/
↔️ Medium, Left-to-right
+
+
+
,
−
-
−
↔️ Low, Left-to-right
In the expression
2
+
2 +
2
+
3
∗
3 *
3
∗
4
4
4
, multiplication is performed before addition due to operator precedence.
What is the result of
20
20 % 7
20
using the modulo operator?
6
See all 43 cards