What is the difference between a value and a literal?
A value is data that a program can store or use; a literal is a value written directly in source code, such as 42 or "Ada".
Study 2 Variables, Data Types, and Expressions with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What is the difference between a value and a literal?
A value is data that a program can store or use; a literal is a value written directly in source code, such as 42 or "Ada".
What is a variable?
A variable is a name associated with a value, allowing a program to refer to, reuse, or update that information.
What does a data type determine?
A data type identifies what kind of value is represented and which operations are appropriate for it.
Is "42" a string or an integer?
True. The string "42" is text, whereas 42 is an integer.
What values can a Boolean contain?
A Boolean has one of two logical values: True or False. Comparisons commonly produce Boolean results.
What is an expression?
An expression is code that evaluates to a value. It can contain literals, variables, operators, function calls, or nested expressions.
What does 2 + 3 * 4 evaluate to?
14. Multiplication has higher precedence than addition, so 3 * 4 is evaluated before 2 is added.
What is the result of 7 // 2 in Python?
3. In Python, // performs floor division, producing the whole-number quotient for 7 divided by 2.
What is the result of 7 % 2?
1. The remainder operator % gives what remains after integer division: 7 % 2 equals 1.
How do = and == differ in Python?
= assigns a value to a variable; == compares two values for equality and produces a Boolean result.
After count = 10 and count = count + 1, what is count?
11. Python evaluates count + 1 using the current value 10, then assigns the result back to count.
What is type conversion?
Type conversion changes a value from one data type to another, such as converting the text "20" to the integer 20 with int().