HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Blog

Account

  • Dashboard
  • My Content
  • Profile
  • Log in
© 2026 senLearn. All rights reserved.HelpAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Problems
  2. /For word = "computer", what are word[0], word[-1], word[2:5] and word[::-1]?
MediumPython ProgrammingMiddle Stage (6–8)High School (9–10)High School (11–12)UndergraduateGeneralPython Basics › StringsConceptualPython-CodedPCEP (Python Institute)

For word = "computer", what are word[0], word[-1], word[2:5] and word[::-1]?

StemPy LabContributed by StemPy Lab

Try it on paper first. A hint, the key idea and the worked solution are here when you need them.

For word = "computer", what are word[0], word[-1], word[2:5] and word[::-1]?

Need a reminder? The key ideaShowHide

Positions start at 0, negative positions count from the end, and a slice stops before its end position.

The worked solution

Have you tried it?

Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, compare your working with the solution.

Write the positions under the letters: c 0, o 1, m 2, p 3, u 4, t 5, e 6, r 7.

  • word[0] is c, the first character.
  • word[-1] is r, the last character.
  • word[2:5] has the characters at 2, 3 and 4, which is mpu. It stops before 5.
  • word[::-1] goes backwards through the whole word: retupmoc.
Log in to save this for later
← All Problems
← For text = "Python Programming", find its length, its capital letters version, its small letters…Show the first letter and the last letter of the word python. →
More onPython Basics › Strings

Discussion (0)

Log in to join the discussion.

Loading…

Learn it in

  1. Slices and string methodsWords and Text: Strings

More on this topic

  1. For the text "the cat sat on the mat", write the program lines that show: how many times at occurs…Medium
  2. A student wants to change the name "Rahul" to "Raju" and writes…Medium
  3. The variable word = "elephant" has eight letters…Easy
  4. The name is "asha rao". Show its initials in capital letters: AR.Hard
For word = "banana", how many times do a, an and n appear?Easy
All problems on this topic →