πŸš€ DevOps & SRE Certification Program πŸ“… Starting: 1st of Every Month 🀝 +91 8409492687 πŸ” Contact@DevOpsSchool.com

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

Python Tutorials: Constants In Python

A constant is an identifier whose value cannot be changed throughout the execution of a program whereas the variable value keeps on changing.
There are no constants in Python, the way they exist in C and Java.
In Python, It is not possible to define constant whose value can not be changed.
In Python, Constants are usually defined on a module level and written in all capital letters with underscores separating words but remember its value can be changed.
Ex:-
PI
TOTAL
MIN_VALUE

# A constant is a type of variable whose value cannot be changed.
# constants are written in all capital letters and underscores separating the words
# In reality, we don't use constants in Python. The globals or constants module is used throughout the Python programs.
- constant.py
PI = 3.14
GRAVITY = 9.8
- main.py
import constant
print(constant.PI)
print(constant.GRAVITY)
Rules and Naming Convention for Variables and constants
# Constant and variable names should have a combination of letters in lowercase (a to z) or uppercase (A to Z) or digits (0 to 9) or an underscore (_). For example:
snake_case
MACRO_CASE
camelCase
CapWords
# Create a name that makes sense. For example, vowel makes more sense than v.
# If you want to create a variable name having two words, use underscore to separate them. For example:
my_name
current_salary
# Use capital letters possible to declare a constant. For example:
PI
G
MASS
SPEED_OF_LIGHT
TEMP
# Never use special symbols like !, @, #, $, %, etc.
# Don't start a variable name with a digit.

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.