Programming ConceptsLesson 4Free preview
Constants
This lesson is part of Intro to Programming · All levels
Summary
This lesson discusses constants, which are fixed values that are set once and cannot change during the program. A constant is used for constant data such as pi or maximum limits, to make code more secure and easy to maintain. Changing a constant generally results in an error, according to its immutable nature.
Key points
- A constant is a value that is fixed once and cannot be changed
- A constant is suitable for a fixed value such as pi, configuration, or limit
- Changing the constant triggers an error in the language that supports it
- Constant clarifies the code's intent and prevents accidental change
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.