Explore topic-wise MCQs in Python.

This section includes 176 Mcqs, each offering curated multiple-choice questions to sharpen your Python knowledge and support exam preparation. Choose a topic below to get started.

151.

Which among the following is/are not a metacharacter?i) \aii) \Aiii) \biv) \B

A. Only i)
B. i) and iii)
C. ii), iii) and iv)
D. ii) and iv)
Answer» B. i) and iii)
152.

Concatenating operator is used for

A. Combining two strings
B. Comparing two strings
C. Arrays concatenation
D. None of them
Answer» B. Comparing two strings
153.

Which syntax is very useful for specifying large chunks of interpolated variable text?

A. Single quoted strings
B. Double quoted strings
C. Heredoc syntax
D. Concatenation syntax
Answer» D. Concatenation syntax
154.

Which statement is correct for specifying a string in code?

A. $my_string = ' A literal string';
B. $my_string = ' A literal string";
C. #my_string = ' A literal string';
D. Both a and b
Answer» E.
155.

Replacing string from left hand side is known as

A. Slicing
B. Dicing
C. Trailing
D. Leading
Answer» E.
156.

A function that capitalizes first letter of each word in a string, is a

A. strtupper ( ) function
B. strword ( ) function
C. unwords ( ) function
D. ucfirst ( ) function
Answer» D. ucfirst ( ) function
157.

By using special wildcards for matching a string which function is used?

A. Strtok
B. Tokenizing
C. Delimiter
D. Regex
Answer» E.
158.

There are how many types of classes for regular expressions?

A. 1
B. 2
C. 3
D. 4
Answer» C. 3
159.

Which function is used to take a string as argument and returns a string that is stripped of all HTML and PHP tags?

A. nl2br ( )
B. strip ( )
C. strip_tags ( )
D. All of them
Answer» D. All of them
160.

What is meaning of "." in POSIX style regex?

A. Matches any character of a string
B. Matches the beginning of a string
C. Matches the end of a string
D. None of them
Answer» B. Matches the beginning of a string
161.

By first constructing a message string and then shipping it off to receiving program, is a way of communication between PHP and

A. Database servers
B. LDAP servers
C. Sockets
D. All of them
Answer» E.
162.

MD5 is not secure to store passwords because

A. Its produces output in hexadecimal values
B. It produces the same output string as given input string
C. It produces Boolean results
D. None of them
Answer» C. It produces Boolean results
163.

POSIX regular expression function ereg_replace ( ) takes

A. 1 argument
B. 2 arguments
C. 3 arguments
D. 4 arguments
Answer» D. 4 arguments
164.

What is the output of the following?

A. (‘we’, ‘are’, ‘humans’)
B. (we, are, humans)
C. (‘we’, ‘humans’)
D. ‘we are humans’
Answer» B. (we, are, humans)
165.

Output of Md5 is

A. 8 octal digest characters
B. 32 hexa digest characters
C. 2 binary digest characters
D. None of them
Answer» C. 2 binary digest characters
166.

Which of them is a HTML specific string function?

A. htmlentities ( )
B. nl2br ( )
C. strip_tags ( )
D. All of them
Answer» E.
167.

Some characteristics of MD5 is

A. Check summing a message
B. Detecting if a file's contents have changed
C. Splitting strings or files into dispersed sets
D. All of them
Answer» E.
168.

Strspn ( ) and strcspn ( ) functions takes 2 srtring arguments while count_chars ( ) takes

A. 1 argument
B. 2 arguments
C. 3 arguments
D. 4 arguments
Answer» B. 2 arguments
169.

Perl-compatible regex patterns are always ended by one particular character, which must be?

A. Same as beginning and end
B. Same at middle and end
C. Different from beginning
D. None of them
Answer» B. Same at middle and end
170.

MD5 takes input string and makes it down into a fixed length string of

A. 32 hexadecimal values
B. 8 octal values
C. 2 binary values
D. None of them
Answer» B. 8 octal values
171.

If errors occurs during transfer of file, you can use

A. MD5 digest along with message
B. nl2br along with message
C. strip_tags along with message
D. None of them
Answer» B. nl2br along with message
172.

Which function from following is not included in PHP6?

A. ereg ( )
B. ereg_replace ( )
C. eregi ( )
D. All of them
Answer» E.
173.

POSIX regex and PERL compatible regex, both are example of

A. Tokenizing
B. Delimitering
C. Regular expressions
D. None of them
Answer» D. None of them
174.

A function that takes two strings and returns a string that is similar in spelling of other

A. count_chars ( )
B. strspon ( )
C. levenshtein ( )
D. All of them
Answer» D. All of them
175.

‘XXXXAA, 4’$

A. (‘AAAAAA’, 4)
B. (‘XXXXAA’, 4)
C. ‘AAAAAA, 4’
Answer» C. ‚Äö√Ñ√∂‚àö√ë‚àö‚â§AAAAAA, 4‚Äö√Ñ√∂‚àö√ë‚àö¬•
176.

[‘M a t h s i s a d i f f i c u l t s u b j e c t’]$

A. [‘Maths’, ‘is’, ‘a’, ‘difficult’, ‘subject’]
B. ‘Maths is a difficult subject’
C. [‘M’, ‘a’, ‘t’, ‘hs is a difficult subject’]
Answer» C. [‚Äö√Ñ√∂‚àö√ë‚àö‚â§M‚Äö√Ñ√∂‚àö√ë‚àö¬•, ‚Äö√Ñ√∂‚àö√ë‚àö‚â§a‚Äö√Ñ√∂‚àö√ë‚àö¬•, ‚Äö√Ñ√∂‚àö√ë‚àö‚â§t‚Äö√Ñ√∂‚àö√ë‚àö¬•, ‚Äö√Ñ√∂‚àö√ë‚àö‚â§hs is a difficult subject‚Äö√Ñ√∂‚àö√ë‚àö¬•]