Skip to main content

← 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] -> Prog
  • text[-3:] -> ing
  • a > b -> True

Common Mistakes

  • Wrong slice end index expectations.
  • Confusing is with == for value comparison.

Practice

  1. Count vowels in a string.
  2. Build expression evaluator for arithmetic operators.

📍 Visit Us

🏫 VD Computer Tuition Surat

VD Computer Tuition
📍 Address
2/66 Faram Street, Rustompura
Surat395002, Gujarat, India
📞 Phone / WhatsApp
+91 84604 41384
🌐 Website

Computer Classes & Tuition — Areas We Serve in Surat

AdajanAlthanAmroliAthwaAthwalinesBhagalBhatarBhestanCanal RoadChowkCitylightDumasGaurav PathGhod Dod RoadHaziraJahangirpuraKamrejKapodraKatargamLimbayatMagdallaMajura GateMota VarachhaNanpuraNew CitylightOlpadPalPandesaraParle PointPiplodPunaRanderRing RoadRustampuraSachinSalabatpuraSarthanaSosyo CircleUdhnaVarachhaVed RoadVesuVIP Road
📞 Call Sir💬 WhatsApp Sir