TechBeamersTechBeamers
  • Viral Tips 🔥
  • Free CoursesTOP
  • TutorialsNEW
    • Python Tutorial
    • Python Examples
    • C Programming
    • Java Programming
    • MySQL Tutorial
    • Selenium Tutorial
    • Selenium Python
    • Playwright Python
    • Software Testing Tutorial
    • Agile Concepts
    • Linux Concepts
    • HowTo Guides
    • Android Topics
    • AngularJS Guides
    • Learn Automation
    • Technology Guides
  • Top Interviews & Quizzes
    • SQL Interview Questions
    • Testing Interview Questions
    • Python Interview Questions
    • Selenium Interview Questions
    • C Sharp Interview Questions
    • Java Interview Questions
    • Web Development Questions
    • PHP Interview Questions
    • Python Quizzes
    • Java Quizzes
    • Selenium Quizzes
    • Testing Quizzes
    • HTML CSS Quiz
    • Shell Script Quizzes
  • ToolsHOT
    • Python Online Compiler
    • Python Code Checker
    • C Online Compiler
    • Review Best IDEs
    • Random Letter Gen
    • Random Num Gen
TechBeamersTechBeamers
Search
  • Viral Tips 🔥
  • Free CoursesTOP
  • TutorialsNEW
    • Python Tutorial
    • Python Examples
    • C Programming
    • Java Programming
    • MySQL Tutorial
    • Selenium Tutorial
    • Selenium Python
    • Playwright Python
    • Software Testing Tutorial
    • Agile Concepts
    • Linux Concepts
    • HowTo Guides
    • Android Topics
    • AngularJS Guides
    • Learn Automation
    • Technology Guides
  • Top Interviews & Quizzes
    • SQL Interview Questions
    • Testing Interview Questions
    • Python Interview Questions
    • Selenium Interview Questions
    • C Sharp Interview Questions
    • Java Interview Questions
    • Web Development Questions
    • PHP Interview Questions
    • Python Quizzes
    • Java Quizzes
    • Selenium Quizzes
    • Testing Quizzes
    • HTML CSS Quiz
    • Shell Script Quizzes
  • ToolsHOT
    • Python Online Compiler
    • Python Code Checker
    • C Online Compiler
    • Review Best IDEs
    • Random Letter Gen
    • Random Num Gen
Follow US
© TechBeamers. All Rights Reserved.
Python Quizzes

Python String Handling Quiz Part-2

Last updated: Apr 13, 2025 2:04 pm
Harsh S.
By
Harsh S.
Harsh S. Avatar
ByHarsh S.
Hello, I'm Harsh, I hold a degree in Masters of Computer Applications. I have worked in different IT companies as a development lead on many large-scale...
Follow:
No Comments
1 month ago
Share
8 Min Read
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

Related

TAGGED:Python Strings
Share This Article
Flipboard Copy Link
Subscribe
Notify of
guest

guest

0 Comments
Newest
Oldest
Inline Feedbacks
View all comments

List of Topics

Stay Connected

FacebookLike
XFollow
YoutubeSubscribe
LinkedInFollow

Subscribe to Blog via Email

Enter your email address to subscribe to latest knowledge sharing updates.

Join 1,011 other subscribers

Continue Reading

  • Python File Handling Quiz Part-1Oct 8
  • Python File Handling Quiz Part-2Oct 13
  • Python Functions Quiz Part-1Oct 16
  • Python Functions Quiz Part-2Oct 16
  • Python Quiz: Classes and Objects Part 1Oct 22
  • Python Quiz for Beginners Part-1Sep 24
  • Python Multithreading QuizNov 13
  • Python Programming Online Skill TestJan 13
  • Python Quiz for Beginners Part-2Feb 3
  • Python Entry-Level Quiz For DevelopersMar 2
View all →

RELATED TUTORIALS

Python File Handling Quiz Part-1 for Beginners

Python File Handling Quiz Part-1

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

Python Functions Quiz Part-2

By Meenakshi Agarwal
3 months ago
Programming Quiz for Python Developers

Python Entry-Level Quiz For Developers

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

Python Quiz: Classes and Objects Part 2

By Meenakshi Agarwal
9 months ago
© TechBeamers. All Rights Reserved.
  • About
  • Contact
  • Disclaimer
  • Privacy Policy
  • Terms of Use
wpDiscuz