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.

101.

MD5 stands for

A. Multi Dimension Algorithm
B. Message Digest Algorithm
C. Message Division Algorithm
D. None of them
Answer» C. Message Division Algorithm
102.

Which function is used for escaping quotation marks, double quotation marks, backslashes and Nulls from a string?

A. remove ( )
B. removeslash( )
C. addslashes ( )
D. None of them
Answer» D. None of them
103.

Which function returns resulting string as its value?

A. printf ( ) function
B. scanf ( ) function
C. sprintf ( ) function
D. None of them
Answer» D. None of them
104.

A sequence of characters that is treated as a unit is called

A. Arrays
B. Functions
C. Methods
D. Strings
Answer» E.
105.

PHP removes ereg functions, and prefer using

A. preg functions
B. energ functions
C. leven functions
D. None of them
Answer» B. energ functions
106.

MD5 algorithm is used to produce a

A. Digest of a string
B. Signature of a string
C. Name of string
D. Both a and b
Answer» E.
107.

Function Strcmp ( ) is equals to

A. Strposs ( )
B. Strrpos ( )
C. Stricmp ( )
D. Strcasecmp
Answer» E.
108.

Strtupper ( ) function returns

A. All uppercase string
B. All lowercase string
C. First letter capitalized
D. None of them
Answer» B. All lowercase string
109.

For creating pages that contain HTML forms and have multiline strings we can use

A. Assignment concatenation syntax
B. Heredoc syntax
C. Concatenation syntax
D. None of them
Answer» C. Concatenation syntax
110.

Concatenating assignment operator is denoted by

A.
B. .
C. ⋅=
D. ⋅=⋅
Answer» D. ⋅=⋅
111.

Which string type is interpreted as a number of sequences and automatically interpolates variable values?

A. Single quoted string
B. Doubly quoted string
C. Numbered string
D. Both a and b
Answer» C. Numbered string
112.

Which PHP function treats a string as collection of characters rather than a sequence?

A. strspn ( )
B. strcspn ( )
C. count_chars
D. All of them
Answer» E.
113.

Why a special character is used in beginning and end of string in Perl-compatible patterns?

A. Because it indicates the beginning and end of the pattern
B. Because it indicates that it?s a integer string
C. Because it indicates the literal
D. It indicates nothing
Answer» B. Because it indicates that it?s a integer string
114.

Chop ( ), ltrim ( ) and trim functions are used for

A. Slicing
B. Dicing
C. Cleaning up untidy strings
D. Concatenation of strings
Answer» D. Concatenation of strings
115.

Htmlspecialchars ( ) function takes a string as argument and returns string in which form, that has a special meaning in HTML

A. Replaces a string with four characters
B. Replaces a string in integers
C. Replaces a string with quotation marks
D. None of them
Answer» B. Replaces a string in integers
116.

Which function is used to implement MD5 in PHP?

A. md ( )
B. digest ( )
C. md5 ( )
D. digest_algo ( )
Answer» D. digest_algo ( )
117.

When two strings are exactly equivalent Strcmp ( ) returns what?

A. Returns a string
B. Returns 0
C. Returns 1
D. Returns nothing
Answer» C. Returns 1
118.

In substring selection which function modifies a string?

A. Strchar ( )
B. Slicing
C. Dicing
D. None of them
Answer» D. None of them
119.

Regex defines a

A. Style
B. Function
C. Regular expression
D. Class
Answer» D. Class
120.

Selecting a substring by numerical position is property of

A. Strstr ( )
B. Substr ( )
C. str ( )
D. Strsub ( )
Answer» E.
121.

Dot ". " operator in strings are called as

A. Assignment operator
B. Concatenation operator
C. Concatenating assignment operator
D. Literal operator
Answer» C. Concatenating assignment operator
122.

What does trailing means in replacement of functions?

A. Replacing string from right hand side
B. Replacing string from left hand side
C. Replacing string from middle
D. None of them
Answer» B. Replacing string from left hand side
123.

Literal string specified in PHP code by

A. Single quotation mark
B. Double Quotation mark
C. Single dollar sign
D. Both a and b
Answer» E.
124.

Which function is used for capitalizing first letter of a string?

A. strtlower ( )
B. strtupper ( )
C. ucfirst ( )
D. lfirst ( )
Answer» D. lfirst ( )
125.

Which of the following would be a potential match for the Perl-based regular expression /fo{2,4}/ ?i) folii) fooliii) fooooliv) fooooool

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

Say we have two compare two strings which of the following function/functions can you use?i) strcmp()ii) strcasecmp()iii) strspn()iv) strcspn()

A. i) and ii)
B. iii) and iv)
C. None of the mentioned
D. All of the mentioned
Answer» E.
127.

For tokenizing a string which PHP function is used?

A. ok ( )
B. strtok ( )
C. str ( )
D. start ( )
Answer» C. str ( )
128.

A function that takes a filename as argument and returns a MD5 of that file

A. md_file( )
B. md5 ( )
C. md5_file ( )
D. digest_file ( )
Answer» D. digest_file ( )
129.

In addition to single and double quoted strings PHP offers another way to specify a string which is called as

A. heredoc
B. Concatenation
C. Literals
D. None of them
Answer» B. Concatenation
130.

Returns a string arguments with trilling blank space removed, is a behavior of

A. starts ( ) function
B. chop ( ) function
C. rtrim ( ) function
D. Both b and c
Answer» E.
131.

PHP offers printf ( ) and

A. printh ( ) function
B. sprintf ( ) function
C. scanf ( ) function
D. All of them
Answer» C. scanf ( ) function
132.

Ltrim ( ) returns its string argument with

A. Leading blankspace removed
B. Trailing blankspace removed
C. Numerical values
D. None of them
Answer» B. Trailing blankspace removed
133.

Returns a string argument with both leading and trailing whitespace removed, is a behavior of

A. chop ( )
B. rtrim ( )
C. trim ( )
D. ltrim ( )
Answer» D. ltrim ( )
134.

Which function is used for replacing whole string with an alternate string?

A. Strstr ( )
B. Strrpos ( )
C. Str_replace ( )
D. Replace ( )
Answer» D. Replace ( )
135.

Stristr ( ) is identical to Strstr ( ) except that

A. The comparison is case independent
B. The comparison start from middle
C. The comparison is case sensitive
D. None of them
Answer» B. The comparison start from middle
136.

Which three functions has intimate relationship with each other?

A. char ( ), str ( ), pos ( )
B. strchar ( ), strcpp ( ), char ( )
C. substr ( ), strstr ( ), strpos ( )
D. None of them
Answer» D. None of them
137.

Ereg ( ) function is no more included in

A. PHP1.0
B. PHP2
C. PHP5
D. PHP6
Answer» E.
138.

Which function takes a single string and returns its length as an integer?

A. Strpos ( )
B. Strcmp ( )
C. strstr ( )
D. Strlen ( )
Answer» E.
139.

PHP has long supported two regular expression implementations known as _______ and _______i) Perlii) PEARiii) Pearliv) POSIX

A. i) and ii)
B. ii) and iv)
C. i) and iv)
D. ii) and iii)
Answer» D. ii) and iii)
140.

Inverse function of explode ( ) is

A. strtok ( )
B. str ( )
C. impose ( )
D. implode ( )
Answer» E.
141.

Which two functions are used for replacing a string with another string?

A. Str_replace ( )
B. Substr_replace ( )
C. Replace ( )
D. Both a and b
Answer» E.
142.

Strstr ( ) function selects a substring by its

A. Numerical value
B. Content
C. Position
D. None of them
Answer» C. Position
143.

Operator that is used for heredoc syntax

A. < >
B. ??
C. [[ ]]
D. <<<
Answer» E.
144.

In Perl-compatible patterns any pattern that is followed by ? this means that

A. Match this pattern 1 or more times
B. Match this pattern exactly 1 time
C. Match this pattern 0 times
D. None of them
Answer» C. Match this pattern 0 times
145.

Which function start its search from backward rather than from beginning?

A. Strcmp ( )
B. Strstr ( )
C. Strpos ( )
D. All of them
Answer» D. All of them
146.

How many operators PHP offer for strings?

A. 2
B. 3
C. 4
D. 5
Answer» B. 3
147.

For finding out one string is equal to another string which function we can use?

A. strpid ( )
B. strpos ( )
C. str ( )
D. All of them
Answer» C. str ( )
148.

All these characters in a string \, ?, *, \, &Hat, $, ] are escaped by

A. remove ( ) function
B. removechar ( )
C. addslashes ( )
D. quotemeta ( )
Answer» E.
149.

All these functions are preg_quote ( ), preg_grep ( ), preg_split ( ), preg_match_all ( ) example of

A. POSIX style regex
B. Competent style regex
C. Perl compatible style regex
D. None of them
Answer» D. None of them
150.

In substring selection what's mean of Slicing?

A. Concatenating
B. Choosing a portion of a string
C. Modifying a string
D. Comparing a string
Answer» C. Modifying a string