TalentJR

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))  # 6

2Accessing 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())   # Hello

4String 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!