PYnative

Python Programming

  • Learn Python
    • Python Tutorials
    • Python Basics
    • Python Interview Q&As
  • Exercises
  • Quizzes
  • Code Editor
Home » Python » Quizzes » Python String Quiz

Python String Quiz

Updated on: August 26, 2025 | 24 Comments

This Python String Quiz provides Multiple Choice Questions (MCQs) to help you get familiar with Python Strings. To perform any programming tasks in Python, a good understanding of string manipulation is necessary. This online quiz focuses on testing your skills in Python String manipulation.

You’ll encounter questions covering:

  • String Creation and Basics: How to define strings, basic properties like length, and immutability.
  • String Indexing and Slicing: Accessing specific characters or substrings using indices and slicing techniques.
  • String Methods: Utilizing built-in string methods for common operations like changing case, searching, replacing, splitting, and joining strings.
  • String Formatting: Different ways to embed variables and expressions within strings.
  • Escape Sequences: Understanding special characters within strings.

Also, See:

  • Python String Exercise
  • 15 Python Quizzes: each focusing on a specific topic
  • The quiz contains 25 questions. There is no time limit.
  • Explanation is provided for each answer.
  • You will get 1 point for each correct answer. Solve 15 correctly to pass the test

1. What will be the output of the following Python code?

path = "/usr/local/bin/python"
print(path.split('/'))
 
 
 
 

2. Guess the correct output of the following code?

str1 = "PYnative"
print(str1[1:4])
print(str1[4:])
 
 
 

3. You have a list of strings words = ["hello", "world", "python"]. How would you join them into a single string "hello-world-python"?

 
 
 
 

4. What will be the output of the following Python code?

s = "Python"
print(s[2:5])
 
 
 
 

5. Python does not support a character type; a single character is treated as strings of length one.

 
 

6. Which method is correct to convert String "welcome to python" to "Welcome To Python"

 
 

7. Which of the following is the most efficient way to concatenate a large number of small strings in a loop?

 
 
 
 

8. Which of the following is the modern (Python 3+) and generally preferred way to format strings, offering better readability and performance than % formatting?

 
 
 
 

9. What will be the output of the following Python code?

s = "Python"
print('o' in s)
print('x' not in s)
 
 
 
 

10. Select the correct output of the following String operations

str1 = "my isname isis jameis isis bond"; 
sub = "is"; 
print(str1.count(sub, 4))
 
 
 

11. What is the purpose of a “raw string” (prefixed with r or R) in Python?

 
 
 
 

12. What will be the output of the following Python code?

str1 = "PYnative"
print(str1[0:-1])
print(str1[:-1])
 
 
 
 

13. What does it mean that strings in Python are “immutable”?

 
 
 
 

14. Choose the correct function to get the character from ASCII number

 
 
 

15. What is the default encoding used for strings in Python 3?

 
 
 
 

16. Which string method returns True if all characters in the string are alphabetic (letters) and there is at least one character?

 
 
 
 

17. What will be the output of the following string operation?

str1 = 'Welcome'
print (str1[:6] + ' PYnative')
 
 
 
 

18. Guess the correct output of the following String operation

str1 = 'Welcome'
print(str1*2)
 
 

19. Which string method is used to count the number of non-overlapping occurrences of a substring in the string?

 
 
 
 

20. Which f-string syntax allows you to print both the variable name and its value for debugging purposes?

 
 
 
 

21. Which string method checks if all characters in the string are digits (0-9) and the string is not empty?

 
 
 
 

22. What will be the output of the following Python code?

data = "item1,item2,item3"
parts = data.split(',')
print(parts[1])
 
 
 
 

23. How would you replace all occurrences of “apple” with “orange” in the string s = "I like apple pie, apple juice."?

 
 
 
 

24. What will be the output of the following string comparison

print("John" > "Jhon")
print("Emma" < "Emm")
 
 

25. What will be the output of the following code?

str1 = "My salary is 7000";
str2 = "7000"

print(str1.isdigit())
print(str2.isdigit())
 
 
 

Loading ... Loading …

Loading

Filed Under: Python, Python Basics, Python Quizzes

Did you find this page helpful? Let others know about it. Sharing helps me continue to create free Python resources.

TweetF  sharein  shareP  Pin

About Vishal

Image

I’m Vishal Hule, the Founder of PYnative.com. As a Python developer, I enjoy assisting students, developers, and learners. Follow me on Twitter.

Related Tutorial Topics:

Python Python Basics Python Quizzes

All Coding Exercises:

C Exercises
C++ Exercises
Python Exercises

Python Exercises and Quizzes

Free coding exercises and quizzes cover Python basics, data structure, data analytics, and more.

  • 15+ Topic-specific Exercises and Quizzes
  • Each Exercise contains 25+ questions
  • Each Quiz contains 25 MCQ
Exercises
Quizzes

Loading comments... Please wait.

In: Python Python Basics Python Quizzes
TweetF  sharein  shareP  Pin

  Python Quizzes

  • 15 Python Quizzes
  • Python Online MCQ Test
  • Basic Quiz For Beginners
  • Variables and Data Types Quiz
  • Functions Quiz
  • if else and loops Quiz
  • Numbers Quiz
  • String Quiz
  • List Quiz
  • Set Quiz
  • Dictionary Quiz
  • Tuple Quiz
  • Operators and Expression Quiz
  • Input and Output Quiz
  • Multithreading and Multiprocessing Quiz
  • File Handling Quiz
  • Random Data Generation Quiz

 Explore Python

  • Python Tutorials
  • Python Exercises
  • Python Quizzes
  • Python Interview Q&A
  • Python Programs

All Python Topics

Python Basics Python Exercises Python Quizzes Python Interview Python File Handling Python OOP Python Date and Time Python Random Python Regex Python Pandas Python Databases Python MySQL Python PostgreSQL Python SQLite Python JSON

About PYnative

PYnative.com is for Python lovers. Here, You can get Tutorials, Exercises, and Quizzes to practice and improve your Python skills.

Follow Us

To get New Python Tutorials, Exercises, and Quizzes

  • Twitter
  • Facebook
  • Sitemap

Explore Python

  • Learn Python
  • Python Basics
  • Python Databases
  • Python Exercises
  • Python Quizzes
  • Online Python Code Editor
  • Python Tricks

Coding Exercises

  • C Exercises
  • C++ Exercises
  • Python Exercises

Legal Stuff

  • About Us
  • Contact Us

We use cookies to improve your experience. While using PYnative, you agree to have read and accepted our:

  • Terms Of Use
  • Privacy Policy
  • Cookie Policy

Copyright © 2018–2025 pynative.com

Advertisement