What is a variable?
A variable is a name associated with a value so a program can use that value later.
Study 02 Variables, Expressions, and Input/Output with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What is a variable?
A variable is a name associated with a value so a program can use that value later.
What does assignment do?
Assignment evaluates the expression on the right and associates its resulting value with the target name. In Python, assignment uses =.
What is a value?
A value is a piece of data, such as a number, character sequence, or Boolean value.
What is a Python constant?
A constant is a value a program intends not to change. Python conventionally uses uppercase names, but does not enforce constancy.
What is a literal?
A literal is a value written directly in source code, such as 42, 3.14, "hello", True, or None.
What is an expression?
An expression is code that produces a value. Examples include 7, price, and price * quantity.
What does += combine?
Augmented assignment combines an operation with assignment; for example, count += 2 has the effect of count = count + 2.
How do = and == differ?
The == operator tests equality and produces a Boolean result, whereas = assigns a value and changes program state.
Why use parentheses in expressions?
Parentheses are evaluated first, followed by exponentiation, multiplication or division, addition or subtraction, comparisons, and logical operators.
What is program state?
Program state is the complete set of values that matter at a particular moment during execution. Assignments change that state.
What type does input() return?
Python's input() reads a line from standard input and returns it as a string, even when the user enters digits.
How do you convert numeric input?
Convert text with int() for integers or float() for floating-point numbers when arithmetic is needed; conversion can fail for invalid input.