Chapter 1 Flashcards
(34 cards)
What is a variable?
A name that holds a value
Variables are fundamental in programming as they store data that can be changed during the execution of a program.
What is an assignment?
Giving a variable a value, like x = 5
Assignment is a key concept in programming where a value is assigned to a variable.
What is an int?
A whole number, like 4
Integers are commonly used in programming for counting and indexing.
What is a float?
A number with a decimal, like 3.5
Floats are used for representing real numbers and are important for calculations that require precision.
What does + do?
Adds numbers
The addition operator can also be used for string concatenation.
What does - do?
Subtracts numbers
Subtraction is a fundamental arithmetic operation in programming.
What does * do?
Multiplies numbers
Multiplication is essential for scaling values and calculations.
What does / do?
Divides numbers
Division can result in float values if the divisor is not a factor of the dividend.
What does // do?
Divides and keeps only the whole number
This is known as floor division and is useful for integer results.
What does ** do?
Raises a number to a power
Exponentiation is used in many mathematical and scientific calculations.
What does % do?
Gives the remainder after dividing
The modulus operator is often used to determine even or odd numbers.
What is order of operations in Python?
Python follows PEMDAS
PEMDAS stands for Parentheses, Exponents, Multiplication and Division (from left to right), Addition and Subtraction (from left to right).
What is a string?
Words or text inside quotes, like ‘hello’
Strings are used to represent textual data.
What is string concatenation?
Adding strings together, like ‘hi’ + ‘bye’ = ‘hibye’
Concatenation is a common operation for combining strings.
What is a Boolean (bool)?
A value that is True or False
Booleans are critical for control flow in programming.
What does == mean?
Equal to
This operator is used for comparison between values.
What does != mean?
Not equal to
The inequality operator is essential for conditional statements.
What does < mean?
Less than
Comparison operators are used to evaluate conditions.
What does > mean?
Greater than
This operator helps in making decisions based on numerical comparisons.
What does <= mean?
Less than or equal to
This operator allows for inclusive comparisons.
What does >= mean?
Greater than or equal to
Similar to <=, it helps in establishing boundaries in comparisons.
What does and mean?
Both sides must be true
The logical AND operator is used in compound conditions.
What does or mean?
One side must be true
The logical OR operator allows for flexible condition checks.
What does not mean?
Switches true to false, or false to true
The NOT operator is used to negate boolean values.