Subscript Expressions 1
Subscript Expressions 1
Control Statement
By
Tunji-Bakare Hannah EDU2412544
Adegoke Rasheedah EDU2412547
ADENIKA Olamide Isaac EDU2012722
CONTENT:
• What are Subscript Expressions?
• Syntax and Usage in Programming
• What are Control Statements?
• Types of Control Statements
• Combining Subscript Expressions
with Control Statements
• Real-world Examples
• Summary
What is a Subscript Expression?
index or key.
dictionaries, etc.
values.
Example (Python):
print(my_list[1]) # Output: 20
Syntax of Subscript Expressions
Example (Dictionary):
• Tuple: tuple[index]
• String: string[index]
in a program.
executed.
2. Looping Statements
3. Jump Statements
Conditional Statements
true.
Examples:
• if
• if...else
• if...elif...else
Python Example:
x = 10
if x > 5:
print("x is greater than 5")
Looping Statements
Types:
• for loop
• while loop
Python Example:
for i in range(3):
print(i)
Jump Statements
Used to control loop execution.
Types:
Python Example:
for i in range(5):
if i == 3:
break
print(i)
Example:
for i in range(len(names)):
if names[i] == "Bob":
print("Found Bob")
numbers = [3, 7, 1, 9, 5]
target = 9
for i in range(len(numbers)):
if numbers[i] == target:
print("Found at index:", i)
break
Real-world Applications
API responses
player status
• AI/ML: Working with tensors and matrices
Summary
• Subscript expressions allow accessing
elements via indices or keys
• Control statements manage the logical flow
of programs
• Used together, they allow powerful data
handling and program logic
REFERENCES
1. “Python Crash Course” by Eric Matthes
• Covers subscript expressions
(indexing/slicing) and control statements in
Python.
• ISBN: 978-1593279288
2. “Introduction to the Theory of Computation”
by Michael Sipser
• Offers foundational concepts on control flow
and computation theory.
3. “C Programming Language” by Brian W.
Kernighan and Dennis M. Ritchie
• Introduces control statements like if, switch,
for, and arrays (subscripted variables).