Python Strings Interview Questions

    Question 1Python Strings - Creation

    Which of the following is a valid way to create a string?

    Question 2Python Strings - Indexing

    What will this code print?

    s = "Python" print(s[0])

    Question 3Python Strings - Negative Index

    What is the output?

    s = "Python" print(s[-1])

    Question 4Python Strings - Slicing

    What will this code output?

    s = "Python" print(s[1:4])

    Question 5Python Strings - Concatenation

    What will this code print?

    s1 = "Hello" s2 = "World" print(s1 + " " + s2)

    Question 6Python Strings - Repetition

    What will be the output?

    s = "Hi" print(s * 3)

    Question 7Python Strings - len() Function

    What does the following return?

    s = "Python" print(len(s))

    Question 8Python Strings - String Methods

    What will this output?

    s = "python" print(s.upper())

    Question 9Python Strings - in Operator

    What will this code print?

    s = "Python" print("tho" in s)

    Question 10Python Strings - strip() Method

    What will this code output?

    s = " Hello " print(s.strip())