Lesson 5
String Operations & Formatting
Work with text and format output beautifully
1String Operations✨
💻 code
# Concatenation (combining)
first = "Hello"
second = "World"
message = first + " " + second💻 code
# Repetition
star = "*"
print(star * 10) # **********💻 code
# Length
text = "Python"
print(len(text)) # 62Accessing Characters🎯
💻 code
word = "Python"
print(word[0]) # P (first character)
print(word[-1]) # n (last character)3String Methods💡
💻 code
text = "hello"
print(text.upper()) # HELLO
print(text.capitalize()) # Hello4String Slicing🚀
💻 code
word = "Python"
print(word[0:2]) # Py
print(word[2:]) # thon💻 code
F-strings (Modern Way)
age = 12
name = "Sarah"
message = f"My name is {name} and I'm {age}"🎯 Practice Challenges
Master String Operations & Formatting by completing all 3 difficulty levels
🟢 EASY
String Operations & Formatting - Easy Challenge
Start with the basics. Perfect for beginners!
🟡 MEDIUM
String Operations & Formatting - Medium Challenge
Get more challenging. Build your confidence!
🔴 HARD
String Operations & Formatting - Hard Challenge
Master this concept. Prove your skills!
🏆 Study a lesson for 2+ minutes to earn +10 TalentJR Points a day. Badges, certificates & prizes →
Ready to Master String Operations & Formatting? 🚀
Complete the challenges, take the quiz and keep your learning streak going!
Keep learning
- ← Previous lessonLesson 4: Getting User InputLearn to make programs interactive with user input
- Next lesson →Lesson 6: First Mini ProjectsBuild real programs using what you've learned
- Grade 6 coursePython Control FlowPython coding course for kids.
- Student ToolsFree calculators for studentsPercentage, fraction, ratio and marks calculators with steps.
- CBSEClass 5 CBSE & NCERT study materialMaths, Science and Computer chapters with solutions.
- Future SkillsExplore future skillsAI, robotics and new-age skills explained for students.