Multiple Choice Questions -strings

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Aparnasunil75
A
Aparnasunil75
Community Contributor
Quizzes Created: 20 | Total Attempts: 43,508
| Attempts: 765 | Questions: 10
Please wait...
Question 1 / 10
0 %
0/100
Score 0/100
1. What will be the output of the following Python statement?    >>>"a"+"bc"

Explanation

The given Python statement is concatenating two strings: "a" and "bc". The output of this statement will be the string "abc".

Submit
Please wait...
About This Quiz
Multiple Choice Questions -strings - Quiz

This quiz on Multiple Choice Questions - Strings assesses understanding of Python string operations. It covers basic operations, slicing, concatenation, and common methods, evaluating practical knowledge essential for programming in Python.

Personalize your quiz and earn a certificate with your name on it!
2. Given a string example="hello" what is the output of example.count('l')?

Explanation

The output of example.count('l') is 2 because the count() method in Python returns the number of occurrences of a specified value in a string. In this case, 'l' appears twice in the string "hello", so the count is 2.

Submit
3. What will be the output of the following Python statement?    >>>"abcd"[2:]

Explanation

The given Python statement is slicing the string "abcd" starting from index 2 till the end of the string. Therefore, the output will be "cd".

Submit
4. A string is a sequence of characters enclosed in ………

Explanation

A string is a sequence of characters enclosed in either single quotes, triple quotes, or double quotes. Single quotes are used to represent a string that contains only one character, while double quotes are used for strings that contain more than one character. Triple quotes are used for multiline strings or strings that span multiple lines. Therefore, all of the options mentioned (single quote, triple quote, and double quote) can be used to enclose a string.

Submit
5. What will be the output of the following Python code? >>>example = "helle" >>>example.find("e")

Explanation

The output of the code will be 1. The find() function in Python returns the index of the first occurrence of the specified substring within the string. In this case, the substring "e" is found at index 1 in the string "helle".

Submit
6. What will be the output of the following Python code? >>>str1="helloworld" >>>str1[::-1]

Explanation

The given code reverses the string "helloworld" using slicing syntax [::-1]. This means it starts from the last character and goes backwards, resulting in the output "dlrowolleh".

Submit
7. The format function, when applied on a string returns ___________

Explanation

The format function, when applied on a string, returns a formatted string. It allows for the insertion of values into specific positions within the string by using placeholders and arguments. The function converts the arguments into strings and replaces the placeholders in the original string with the corresponding values. Therefore, the correct answer is "str" as the format function returns a string.

Submit
8. What will be the output of the following Python code? >>>example = "helle" >>>example.rfind("e")

Explanation

The output of the code will be 4. The rfind() function in Python returns the highest index of the substring "e" in the string "helle". Since "e" appears at index 1 and index 4 in the string, the highest index is 4.

Submit
9. What arithmetic operators cannot be used with strings

Explanation

The operator "-" cannot be used with strings. This is because the "-" operator is used for subtraction in arithmetic operations, and it does not have any meaning when applied to strings. Strings are sequences of characters, and subtraction is not a meaningful operation for them. Therefore, the "-" operator cannot be used with strings.

Submit
10. ) What will be the output of the following Python code? 1. >>>example="helloworld" 2.>>>example[::1].startswith("d")

Explanation

The given Python code first assigns the string "helloworld" to the variable "example". Then, it uses slicing with a step of 1 (i.e., [::1]) to reverse the string. The reversed string is "dlrowolleh". Finally, the code checks if the reversed string starts with the letter "d". Since it does, the output will be "true".

Submit
View My Results

Quiz Review Timeline (Updated): Mar 21, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Mar 16, 2020
    Quiz Created by
    Aparnasunil75
Cancel
  • All
    All (10)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
What will be the output of the following Python statement? ...
Given a string example="hello" what is the output of...
What will be the output of the following Python statement? ...
A string is a sequence of characters enclosed in...
What will be the output of the following Python code? ...
What will be the output of the following Python code? ...
The format function, when applied on a string returns ___________
What will be the output of the following Python code? ...
What arithmetic operators cannot be used with strings
) What will be the output of the following Python code? ...
Alert!

Advertisement