python-practicals (1)
python-practicals (1)
def show_python_keywords():
# Get all Python keywords
all_keywords = keyword.kwlist
show_python_keywords()
Output:
List of Python Keywords:
1. False
2. None
3. True
4. and
...
Example usage of keywords:
Number: 0
Number: 2
1
print(f"Addition: {a + b}")
print(f"Subtraction: {a - b}")
print(f"Multiplication: {a * b}")
print(f"Division: {a / b}")
print(f"Floor Division: {a // b}")
print(f"Modulus: {a % b}")
print(f"Exponentiation: {a ** b}")
# Comparison Operators
print("\nComparison Operators:")
print(f"Equal to: {a == b}")
print(f"Not equal to: {a != b}")
print(f"Greater than: {a > b}")
# Logical Operators
print("\nLogical Operators:")
print(f"AND: {True and False}")
print(f"OR: {True or False}")
print(f"NOT: {not True}")
demonstrate_operators()
Output:
Arithmetic Operators:
Addition: 13
Subtraction: 7
Multiplication: 30
Division: 3.3333333333333335
Floor Division: 3
Modulus: 1
Exponentiation: 1000
Comparison Operators:
Equal to: False
Not equal to: True
Greater than: True
Logical Operators:
AND: False
OR: True
NOT: False
2
statements.
def demonstrate_control_statements():
# if-elif-else statement
score = 85
print("Grade Calculation:")
if score >= 90:
grade = 'A'
elif score >= 80:
grade = 'B'
elif score >= 70:
grade = 'C'
else:
grade = 'D'
print(f"Score: {score}, Grade: {grade}")
demonstrate_control_statements()
Output:
Grade Calculation:
Score: 85, Grade: B
3
ceed with more? Each practical will follow the same format with clear objectives,
code examples, and outputs.]