tech beamers
  • Python Lab
    • Python Online Compiler
    • Python Code Checker
    • Python Coding Exercises
    • Python Coding Quizzes
  • SQL Practice
  • Selenium Practice
  • SW Guides
tech beamers
Search
  • Python Lab
    • Python Online Compiler
    • Python Code Checker
    • Python Coding Exercises
    • Python Coding Quizzes
  • SQL Practice
  • Selenium Practice
  • SW Guides
Follow US
© TechBeamers. All Rights Reserved.
Python Quizzes

Python String Handling Quiz Part-2

Last updated: Dec 29, 2025 6:30 pm
Harsh S.
By Harsh S.
No Comments
3 weeks ago
SHARE

Greetings readers, this is our second quiz on Python string functions. This quiz is more towards testing the Python developer skills to a slightly advanced usage of string functions. Almost all the questions will give you a Python illustration to solve. During the quiz, you may need to execute the sample code. So you can start any of these online Python interpreters. We’ve created this test so that any software engineer can check his Python string knowledge. It’s a good option to train in Python online and become aware of the areas for improvement. We always pick the best questions, most of these come from the people who share their experience after going through the Python job interview.

We’ll soon publish a post along with a quiz on data analytics and machine learning. Our effort is always to bring something new and innovate even with the old topics. There is regular brainstorming to ensure the integrity of all the questions and answers. So, please go through the following interview questions for Python programmers. Next, socket programming and multi-threading are some of the important topics that you might want to learn so check this post Complete Guide to Socket Programming for Python Developers. You can refer to it to groom your knowledge of Python sockets.

🔹 Solve Quiz – Python String Functions

Note: You can review all the answers at the end of this quiz. To learn more about the strings in Python, please refer to our guide to Python strings.

Answer Explanations

#QuestionCorrect Answer(s)Explanation
1What will this code output?*example**center(10, '*') pads the string to width 10, placing '*' on both sides.
2How does center() work in this code?*****python*****center(15, '*') pads the string evenly with '*' on both sides.
3What is the output of count()?2Counts occurrences of 'ab' in the string starting from index 2 not from 0th index.
4How many times does 'ab' appear?3Counts 'ab' within the specified range (-17, -1).
5Which prints list items on new lines?print(‘\n’.join(identity))join('\n') concatenates list items with newlines.
6Default encoding for str.encode()?utf-8encode() uses utf-8 by default unless specified otherwise.
7What does expandtabs(4) do?Welcome To Python ProgrammingReplaces \t with 4 spaces for uniform spacing.
8Will isnumeric() return True for '2.15'?Falseisnumeric() only returns True for whole numbers (not decimals).
9What happens when calling lower()?hello@john!!Converts all uppercase letters to lowercase; special characters remain unchanged.
10What does partition('cd') return?(‘ab’, ‘cd’, ‘efcdyz’)partition('cd') splits into three parts: before, match, and after.
11How will split('cd', 2) behave?[‘ab’, ‘ef’, ‘yzcd’]Splits at 'cd' twice, keeping remaining string intact.
12What does str.title() return?Python String ConceptsCapitalizes the first letter of each word.
13What is the output of splitlines()?[‘PYTHON’, ‘String’, ‘Concepts’]Splits at \n but removes it from output.
14What does zfill(5) return?000amzfill(5) pads the string with zeros until length is 5.
15How does zfill() handle '+55'?+0055zfill(5) ensures width is 5, keeping + at the start.

Key Takeaways from the Python String Quiz-2

So, did you enjoy the quiz? We hope you would like to solve the different questions on the Python string functions. Special thanks to you for taking the time to run through this quiz. We urge you not to just leave from here instead try some more cool quizzes and tutorials on Java/Python/Selenium and related programming articles from our blog.

We have a firm belief that spreading knowledge is a step to enhance it further. When readers review our work and share their feedback, they drive us to deliver better. That’s why we always request them to drop their response in the comment box.

Lastly, please share part 2 of the Python string functions with your friends and on the social media platforms of your choice.

All the Best,
TechBeamers

TAGGED:Python Strings
Share This Article
Whatsapp Whatsapp LinkedIn Reddit Copy Link
Harsh S. Avatar
ByHarsh S.
Follow:
Harsh S., MCA graduate, has 8+ years leading development on IT projects, specializing in Python, Java, unit testing, and CI/CD. At TechBeamers, Harsh authors tutorials, quizzes, and exercises on programming and AI/Data Science.
Previous Article Best Python string handling questions Python String Handling Quiz Part-1
Next Article Python File Handling Quiz Part-1 for Beginners Python File Handling Quiz Part-1
Leave a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Most Popular This Month

  • → Python Online Compiler
  • → Python Code Checker
  • → Free Python Tutorial
  • → SQL Practice Queries
  • → Code to Flowchart Tool
  • → Python Syntax Guide
  • → Python List & Dict Questions
  • → Selenium Practice Test Page

RELATED TUTORIALS

Python DSA Quiz – Part 4 | Trees & Binary Search Tree (BST) MCQ

Python DSA Quiz – Part 4 | Trees & Binary Search Tree (BST) MCQ

By Meenakshi Agarwal
2 months ago
Python Functions Quiz Part-2 for Experienced Programmers

Python Functions Quiz Part-2

By Meenakshi Agarwal
11 months ago
Python programming quiz

Python Quiz for Beginners Part-1

By Meenakshi Agarwal
3 weeks ago
Python Online Quiz - 21 Coding Snippets.

Python Quiz: Classes and Objects Part 2

By Meenakshi Agarwal
1 year ago
© TechBeamers. All Rights Reserved.
  • About
  • Contact
  • Disclaimer
  • Privacy Policy
  • Terms of Use