constant
A name for a value that is set once and is not meant to change while the program runs.
In more detail
Constants suit limits and codes that must not change, such as a maximum retry count, and a named constant explains what a bare number means. Some languages enforce constants, as Go does with const, while others such as Python rely on the convention of writing the name in capitals.
Examples
const maxProbes = 3PI = 3.14159
def circleArea(r):
return PI * r * rRelated terms
- iota — A Go keyword usable only inside a const block, where it counts 0, 1, 2 and so on, used to number a set of related constants.
- named type — A new type you declare with the type keyword, based on an existing one, such as type state int.
- global variable — A variable defined at the top level of a program or module, shared by all the code in that process.
- pi — The ratio of a circle's circumference to its diameter, about 3.14159, available in Python as math.pi.
- snake_case — Writing a multi-word name in lower case with underscores between words, as in tell_story, the Python standard for functions and variables.
Taught in
- Variables, Typing, and Zero Values — Concurrent Systems Programming with Go
- Files and the os Package — Concurrent Systems Programming with Go
- The time Package — Concurrent Systems Programming with Go
- Local Scope And Global Constants — Hands-on Python: Complete Video Course & Book
- Animation: Moving One Shape — Hands-on Python: Complete Video Course & Book
- Any Type As A Condition — Hands-on Python: Complete Video Course & Book
- Formatting, Linting And Style — Hands-on Python: Complete Video Course & Book
- Literals, Names And Four Number Bases — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Import Variants, dir() And sys.path — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Modules Sprint — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Streams, Handles And Open Modes — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep