PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

Python · Theory

Python Strings

← All stacks

Theory

17/268

Python Strings

A string is text — an ordered row of characters. "Asha" or 'Asha'. Multi-line with triple quotes. Index from 0: s[0] is A. s[-1] is the last letter. Slice s[1:3] is sh. Concatenate with +. Repeat with *. "sh" in "Asha" is True.

Strings cannot change in place. s[0] = "B" → TypeError. Methods return a new string. f"Hi {name}" inserts values. That immutability word is what interviews want. Then one slice and one f-string.

Python Strings — output — A, Ash, Hi Asha. Slice end is exclusive. String itself did not change.

Exam tip

Immutability + slice + f-string.

Example

# Strings
name = "Asha"
print(name[0])
print(name[0:3])
print(f"Hi {name}")

Python Strings — output: A, Ash, Hi Asha. Slice end is exclusive. String itself did not change.

Short notes

  • DefText sequence. Immutable.
  • RuleIndex / slice. f-strings.
  • Traps[0] = "H" → TypeError.

Questions

1

Explain Strings as if you are teaching a junior — definition, then one tiny script.

2

What does the example print, and why?

3

What mistake do freshers make with Strings?

Previous← Type Casting in PythonNextPython String Methods →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.