Page 425 - ComputerScience_Class_11
P. 425
Program 2: To demonstrate valid and invalid identifiers in Python.
Program 2.py
File Edit Format Run Options Window Help
# Valid Identifiers
total = 100 # contains only letters
_count = 50 # starts with underscore
marks1 = 90 # contains letters and digits
print("Total:", total)
print("Count:", _count)
print("Marks:", marks1)
# Invalid Identifiers (Uncommenting these will cause errors)
# 1sum = 45 # Error: Cannot start with a digit
# for = 10 # Error: 'for' is a keyword
# total-marks = 80 # Error: Hyphen (-) is not allowed
# @value = 20 # Error: Special symbols are not allowed
# Case Sensitivity Example
name = "Rahul"
Name = "Aman"
NAME = "Riya"
print("name:", name)
print("Name:", Name)
print("NAME:", NAME)
Output
Total: 100
Count: 50
Marks: 90
name: Rahul
Name: Aman
NAME: Riya
12.9.3 Literals
In Python, literals are fixed or constant values that are written directly in a program. They represent data that does not
change during the execution of the program.
Types of literals:
The different types of literals in Python are given below:
Numeric literals: x = 10
y = 3.14
z = 5+2j
String literals: name = "Python"
msg = 'Hello'
Boolean literals: a = True
b = False
Special literal: x = None
Installation & IDE and Fundamentals of Python Programming 423

