← Back to Python Course Foundations
Strings and Operators (Python)¶
Learning Objectives¶
- Perform slicing and indexing.
- Use common string methods.
- Apply arithmetic, logical, identity, and membership operators.
Example¶
text = "Programming"
print(text[0:4])
print(text[-3:])
print(text.upper())
a, b = 10, 3
print(a + b, a > b, a in [10, 20])
Dry Run¶
text[0:4]->Progtext[-3:]->inga > b->True
Common Mistakes¶
- Wrong slice end index expectations.
- Confusing
iswith==for value comparison.
Practice¶
- Count vowels in a string.
- Build expression evaluator for arithmetic operators.