Examples of Identifiers in Programming
Below are some examples of different types of identifiers in programming:
# Variable Identifier
num_students = 100
# Function Identifier
def calculate_area(length, width):
return length * width
# Class Identifier
class Rectangle:
def __init__(self, length, width):
self.length = length
self.width = width
def area(self):
return self.length * self.width
# Constant Identifier
PI = 3.14159
# Label Identifier
start = 1
end_loop = 10
# Function call using Actual Parameters
result = calculate_area(5, 4)
# Object creation using Class Identifier
rectangle = Rectangle(5, 4)
rectangle_area = rectangle.area()
# Output
print("Number of students:", num_students)
print("Area calculated:", result)
print("Rectangle area:", rectangle_area)
print("Value of PI:", PI)
print("Start:", start)
print("End loop:", end_loop)
Output
Number of students: 100 Area calculated: 20 Rectangle area: 20 Value of PI: 3.14159 Start: 1 End loop: 10
What are Identifiers in Programming?
Identifiers are names given to various programming elements, such as variables, functions, classes, constants, and labels. They serve as labels or handles that programmers assign to program elements, enabling them to refer to these elements and manipulate them within the code. In this article, we will learn about the basics of Identifiers, and its use cases.