QUIZ ON : PROGRAMMING AND PROBLEM SOLVING THROUGH PYTHON - INTRODUCTION TO PYTHON

INTRODUCTION TO PYTHON

00:00:00

What will be the output of the following Python code snippet?

print(''''''.isspace())

Option A. True
Option B. False
Option C. None
Option D. Error
True Answer B

Explanation :
None.

What will be the output of the following Python code snippet?

print(''''''.isspace())

Question No# : 01 out of 20



You can create program in Python, in Script Mode

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

You can create program in Python, in Script Mode

Question No# : 02 out of 20

What will be the output of the following Python code snippet?

print('0xa'.isdigit())

Option A. True
Option B. False
Option C. None
Option D. Error
True Answer B

Explanation :
Hexadecimal digits aren’t considered as digits (a-f).

What will be the output of the following Python code snippet?

print('0xa'.isdigit())

Question No# : 03 out of 20



What will be the output of the following Python code snippet?

print('xyyxyyxyxyxxy'.replace('xy', '12', 0))

Option A. xyyxyyxyxyxxy
Option B. 12y12y1212x12
Option C. 12yxyyxyxyxxy
Option D. xyyxyyxyxyx12
True Answer A

Explanation :
The first 0 occurrences of the given substring are replaced.

What will be the output of the following Python code snippet?

print('xyyxyyxyxyxxy'.replace('xy', '12', 0))

Question No# : 04 out of 20



Which of the following cannot be a variable?

Option A. __init__
Option B. in
Option C. it
Option D. on
True Answer B

Explanation :
in is a keyword which is used to check if a value is present in a list, tuple, etc.

Which of the following cannot be a variable?

Question No# : 05 out of 20



What will be the output of the following Python code snippet?

print('ab cd-ef'.title())

Option A. Ab cd-ef
Option B. Ab Cd-ef
Option C. Ab Cd-Ef
Option D. None of the mentioned
True Answer C

Explanation :
The first letter of every word is capitalized. Special symbols terminate a word.

What will be the output of the following Python code snippet?

print('ab cd-ef'.title())

Question No# : 06 out of 20



What will be the output of the following Python code snippet?

print('Ab!2'.swapcase())

Option A. AB!@
Option B. ab12
Option C. aB!2
Option D. aB1@
True Answer C

Explanation :
Lowercase letters are converted to uppercase and vice-versa.

What will be the output of the following Python code snippet?

print('Ab!2'.swapcase())

Question No# : 07 out of 20



Python code can run on a variety of platforms, it means Python is a _____ language.

Option A. Graphical
Option B. Cross-platform
Option C. Independent
Option D. All of these
True Answer B

Explanation :

Python code can run on a variety of platforms, it means Python is a _____ language.

Question No# : 08 out of 20

What will be the output of the following Python code?

print('a'.maketrans('ABC', '123'))

Option A. {97: 49, 98: 50, 99: 51}
Option B. {65: 49, 66: 50, 67: 51}
Option C. {97: 49}
Option D. 1
True Answer B

Explanation :
maketrans() is a static method so it’s behaviour does not depend on the object from which it is being called.

What will be the output of the following Python code?

print('a'.maketrans('ABC', '123'))

Question No# : 09 out of 20



What will be the output of the following Python code snippet?

print('a@ 1,'.islower())

Option A. True
Option B. False
Option C. None
Option D. Error
True Answer A

Explanation :
There are no uppercase letters.

What will be the output of the following Python code snippet?

print('a@ 1,'.islower())

Question No# : 10 out of 20



What will be the output of the following Python code?

print('ab'.isalpha())

Option A. True
Option B. False
Option C. None
Option D. Error
True Answer A

Explanation :
The string has only letters.

What will be the output of the following Python code?

print('ab'.isalpha())

Question No# : 11 out of 20



To convert the read value through input() into integer type, ______ () is used

Option A. floating
Option B. float
Option C. int
Option D. integer
True Answer C

Explanation :

To convert the read value through input() into integer type, ______ () is used

Question No# : 12 out of 20

To give a different separator with print() ______ argument is sued.

Option A. sep
Option B. separator
Option C. end
Option D. tab
True Answer A

Explanation :

To give a different separator with print() ______ argument is sued.

Question No# : 13 out of 20

Python variables support dynamic typing

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

Python variables support dynamic typing

Question No# : 14 out of 20

0128 is a legal literal value in Python

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer B

Explanation :

0128 is a legal literal value in Python

Question No# : 15 out of 20

You can rename keyword in Python

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer B

Explanation :

You can rename keyword in Python

Question No# : 16 out of 20

What will be the output of the following Python code?

print('abcd'.partition('cd'))

Option A. (‘ab’, ‘cd’, ”)
Option B. (‘ab’, ‘cd’)
Option C. error
Option D. none of the mentioned
True Answer A

Explanation :
The last item is a null string.

What will be the output of the following Python code?

print('abcd'.partition('cd'))

Question No# : 17 out of 20



What will be the output of the following Python code snippet?

print('abcefd'.replace('cd', '12'))

Option A. ab1ef2
Option B. abcefd
Option C. ab1efd
Option D. ab12ed2
True Answer B

Explanation :
The first substring is not present in the given string and hence nothing is replaced.

What will be the output of the following Python code snippet?

print('abcefd'.replace('cd', '12'))

Question No# : 18 out of 20



which of the following is an escape sequence for a tab character

Option A. \a
Option B. \t
Option C. \n
Option D. \b
True Answer B

Explanation :

which of the following is an escape sequence for a tab character

Question No# : 19 out of 20

What will be the output of the following Python code?

print('ab12'.isalnum())

Option A. True
Option B. False
Option C. None
Option D. Error
True Answer A

Explanation :
The string has only letters and digits.

What will be the output of the following Python code?

print('ab12'.isalnum())

Question No# : 20 out of 20