Python Strings Quiz: Python Strings Multiple Choice Questions and Answers

Python Strings Quiz with answers and explanations for placement tests and job interviews. This solved Python Strings Quiz is useful for the campus placement for all freshers including Engineering Students, MCA students, Computer and IT Engineers, etc.

Our Python Strings Quiz focuses on all areas of Python and its concept. We will regularly update the quiz and most interesting thing is that questions come in a random sequence. So every time you will feel new questions.

We have already published a blog post that contains short questions on Python If you want you can also see this blog post “Python interview questions“.

 

There are several Python courses that you may have come across during your search for learning Python. Our team of experts has carefully analyzed some Python courses for you. You can check the courses, Trial of some courses is free.

 

Guideline of Python Strings Quiz:

This Python Strings Quiz is intended for checking your Python knowledge. It takes 40 minutes to pass the Python Data Types Quiz. If you don’t finish the Python Strings Quiz within the mentioned time, all the unanswered questions will count as wrong. You can miss the questions by clicking the “Next” button and return to the previous questions by the “Previous” button. Every unanswered question will count as wrong. MCQ on Python Data Types has features of randomization which feel you a new question set at every attempt.

In this Python Strings Quiz, we have also implemented a feature that not allowed the user to see the next question or finish the quiz without attempting the current Python Strings Quiz.

0 votes, 0 avg

You have 40 minutes to take the Python Strings MCQs

Your time has been Over.


Python Strings Quiz

Python MCQ

Python Strings Quiz: Python Strings Multiple Choice Questions and Answers

1 / 32

What is the output of the following Python Programs?

my_string = "Aticleworld"
i = "b"
while i in my_string: 
    print(i, end =" ")

 

2 / 32

Choose the correct function to get the ASCII code of a character

3 / 32

What is the output of the following program?

a = "Aticleworld "
b = 13
print (a + b)

 

4 / 32

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

5 / 32

Suppose s is assigned as follows:

s = 'foobar'

All of the following expressions produce the same result except one. Which one?

6 / 32

Write the code for a Python function expand(x) that takes a list of strings, concatenates them, and returns the resulting string repeated three times.

Example 1:

Input: ['string1', 'string2']
Output: 'string1string2string1string2string1string2'

Example 2:

Input: ['a', 'b', 'c']
Output: 'abcabcabc'

 

7 / 32

A bytes object is immutable. If you want a binary sequence that can be modified, you should use a bytearray. Is it possible to create a bytearray object directly from a bytes object, as shown below:

array_of_bytes = bytearray(b'15\x80a#')

 

8 / 32

What is the output of the following Python Programs?

var1 = 'Aticleworld!'  
var2 = "Free learning is our Goal"
 
print ( var1[0], var2[1:5])

 

9 / 32

In Python, strings are…

10 / 32

The minsplit parameter to split() specifies the minimum number of splits to make to the input string.

11 / 32

Suppose s is assigned as follows:

s = 'foo-bar-baz'

Which of the following expressions evaluates to a string equal to s:

 

12 / 32

What is the output of the following Python Programs?

str1 = "Aticleworld";
str2 = "2016"

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

 

13 / 32

What is the output from this print() function call:

print(
    '$100 $200 $300'.count('$'),
    '$100 $200 $300'.count('$', 5, 10),
    '$100 $200 $300'.count('$', 5)
)

 

14 / 32

What is the output of the following Python Programs?

a = 2
b = '3.77'
c = -8
str1 = '{0:.4f} {0:3d} {2} {1}'.format(a, b, c) 
print(str1)

 

15 / 32

If you want to transform a list of strings input_list into a single string with a comma between each item, which of the following would you give as the input to join()?

16 / 32

Python strings have a property called “immutability.” What does this mean?

17 / 32

What is the output of the following Python Programs?

str1 = "Aticleworld"
print(str1[1:4], str1[:5], str1[4:], str1[0:-1], str1[:-1])

 

18 / 32

What is the output of the print() function call?

s = 'foo'
t = 'bar'
print('barf' in 2 * (s + t))

 

19 / 32

What is the output of the following Python Programs?

a = "Aticleworld"
print(a.count("i"))

 

20 / 32

What is the output of the following program?

line = "What will have so will"
L = line.split('a') 
for i in L: 
    print(i, end=' ')

 

21 / 32

Which of the following would separate a string input_string on the first 2 occurences of the letter “e”?

22 / 32

What is the result of this statement?

print(ord('foo'))

 

23 / 32

You want to create a bytes object consisting of five null (0x00) bytes. All of the following will work except one. Select the one that doesn’t work:

24 / 32

What is the output of the following Python Programs?

Line1 = "Aticleworld is best place to learn "
Line2 = "programming language"
Line3 = "Driver and microcontroller"
Line4 = Line1 + Line2 + Line3
print("best" in Line4)

 

25 / 32

What is the result of the following statement:

list((b'abcde' + 'fghi')[3:6])

 

26 / 32

What is the output of the following Python Programs?

var1 = 'Aticleworld'
 
print(var1[:4] + 'for' + 'Learn')

 

27 / 32

What is the slice expression that gives every third character of string s, starting with the last character and proceeding backward to the first?

28 / 32

You want to create a bytes object consisting of five null (0x00) bytes. All of the following will work except one. Select the one that doesn’t work:

29 / 32

Which of the following mathematical operators can be used to concatenate strings:

30 / 32

Which of the following are true:

s = 'foobar'

 

31 / 32

What is the output of the following program?

print ('x25x26')

 

32 / 32

What is the output of the following Python Programs?

str1 = '{2}, {1} and {0}'.format('a', 'b', 'c') 
str2 = '{0}{1}{0}'.format('abra', 'cad') 
print(str1, str2)

 

Your score is

The average score is 0%

0%

Recommended Articles for you: