MCQOPTIONS
Saved Bookmarks
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.
| 1. |
What does the function re.search do? |
| A. | matches a pattern at the start of the string |
| B. | matches a pattern at any position in the string |
| C. | such a function does not exist |
| D. | none of the mentioned |
| Answer» C. such a function does not exist | |
| 2. |
What does the function re.match do? |
| A. | matches a pattern at the start of the string |
| B. | matches a pattern at any position in the string |
| C. | such a function does not exist |
| D. | none of the mentioned |
| Answer» B. matches a pattern at any position in the string | |
| 3. |
Which of the following creates a pattern object? |
| A. | re.create(str) |
| B. | re.regex(str) |
| C. | re.compile(str) |
| D. | re.assemble(str) |
| Answer» D. re.assemble(str) | |
| 4. |
Which module in Python supports regular expressions? |
| A. | re |
| B. | regex |
| C. | pyregex |
| D. | none of the mentioned |
| Answer» B. regex | |
| 5. |
What will be the output of the following PHP code? |
| A. | rror |
| B. | sername must be all lowercase! |
| C. | sername is all lowercase! |
| D. | o Output is returned |
| Answer» C. sername is all lowercase! | |
| 6. |
[:alpha:] can also be specified as. |
| A. | A-Za-z0-9] |
| B. | A-za-z] |
| C. | A-z] |
| D. | a-z] |
| Answer» C. A-z] | |
| 7. |
Which among the following is/are not a metacharacter?1. /a2. /A3. /b4. /B |
| A. | nly 1 |
| B. | and 3 |
| C. | , 3 and 4 |
| D. | and 4 |
| Answer» B. and 3 | |
| 8. |
Which of the following would be a potential match for the Perl-based regular expression /fo{2,4}/ ?1. fol2. fool3. fooool4. fooooool |
| A. | nly 1 |
| B. | and 3 |
| C. | , 3 and 4 |
| D. | and 4 |
| Answer» C. , 3 and 4 | |
| 9. |
What will be the output of the following PHP code? |
| A. | his is some text that we might like to parse. |
| B. | rray ( [0] => some text that [1] => we might like to parse. ) |
| C. | rray ( [0] => this is [1] => some text that [2] => we might like to parse. ) |
| D. | 0] => this is [1] => some text that [2] => we might like to parse. |
| Answer» E. | |
| 10. |
Say we have two compare two strings which of the following function/functions can you use?1. strcmp()2. strcasecmp()3. strspn()4. strcspn() |
| A. | and 2 |
| B. | and 4 |
| C. | one of the mentioned |
| D. | ll of the mentioned |
| Answer» E. | |
| 11. |
What will be the output of the following PHP code? |
| A. | email protected] |
| B. | ontact |
| C. | email protected] |
| D. | xamveda.com |
| Answer» E. | |
| 12. |
What will be the output of the following PHP code? |
| A. | ontact the author of this article at [email protected]@mple.com |
| B. | email protected] the @uthor of this @rticle @t [email protected]@[email protected] |
| C. | ontact the author of this article at [email protected]@[email protected] |
| D. | rror |
| Answer» D. rror | |
| 13. |
What will be the output of the following PHP code? |
| A. | y name is Will Pitt I am great |
| B. | y name is not Will Pitt I am great |
| C. | y name is Will Pitt I am not great |
| D. | y name is not Will Pitt I am not great |
| Answer» D. y name is not Will Pitt I am not great | |
| 14. |
What will be the output of the following PHP code? |
| A. | ou like dogs. I hate dogs. We should marry. |
| B. | rray([0]=>You like dogs. I hate dogs. We should marry.) |
| C. | rray([0]=>You like dogs. [1]=>I hate dogs. [2]=>We should marry.) |
| D. | rror |
| Answer» D. rror | |
| 15. |
Consider the following commands.$ sed -n ‘1,2p’ emp.lst$ sed -n ‘3,$!p’ emp.lstThe output of both commands will be same. |
| A. | True |
| B. | False |
| C. | May be |
| D. | Can't say |
| Answer» B. False | |
| 16. |
The interval regular expression uses the character _______ |
| A. | { |
| B. | } |
| C. | { and } |
| D. | ( and ) |
| Answer» D. ( and ) | |
| 17. |
What will be the function of the following command?$ sed ‘s/ *|/|/g’ emp.lst |
| A. | replace * with | |
| B. | replace / with | |
| C. | compress multiple spaces |
| D. | erroneous output |
| Answer» D. erroneous output | |
| 18. |
The name of the input and output files cannot be same while using sort command. |
| A. | True |
| B. | False |
| C. | May be |
| D. | Can't say |
| Answer» C. May be | |
| 19. |
For running a UNIX command within awk, we’ve to use ____ function. |
| A. | length |
| B. | substr |
| C. | system |
| D. | split |
| Answer» D. split | |
| 20. |
awk has some built-in functions which are used for arithmetic and string operations. |
| A. | True |
| B. | False |
| C. | May be |
| D. | Can't say |
| Answer» B. False | |
| 21. |
Filter’s are a category of commands that take the advantage of shell redirection feature. |
| A. | True |
| B. | False |
| C. | May be |
| D. | Can't say |
| Answer» B. False | |
| 22. |
For splitting a line or expression into fields, __ is used. |
| A. | foreach |
| B. | for |
| C. | split |
| D. | join |
| Answer» D. join | |
| 23. |
awk makes a distinction between numeric and string variables. |
| A. | True |
| B. | False |
| C. | May be |
| D. | Can't say |
| Answer» C. May be | |
| 24. |
What is the output of the following function? |
| A. | [“hello”] |
| B. | [ ] |
| C. | hello |
| D. | hello world |
| Answer» C. hello | |
| 25. |
What is the output of the code shown? |
| A. | 8 |
| B. | 32 |
| C. | 64 |
| D. | 256 |
| Answer» E. | |
| 26. |
The snippet of code shown below results in an error. State whether true or false. |
| A. | True |
| B. | False |
| C. | May be |
| D. | Can't say |
| Answer» C. May be | |
| 27. |
What is the output of the function shown below? |
| A. | ‘YXAAAA’ |
| B. | (‘YXAAAA’) |
| C. | (‘AAAAAA’) |
| D. | ‘AAAAAA’ |
| Answer» E. | |
| 28. |
What is the output of the code shown below? |
| A. | (‘welcome’, ‘home’) |
| B. | [‘welcome’, ‘home’] |
| C. | welcome home |
| D. | [‘welcome’ // ‘home’ ] |
| Answer» D. [‘welcome’ // ‘home’ ] | |
| 29. |
The output of the code shown below is: |
| A. | No outputA new day |
| B. | No outputNo output |
| C. | [‘A’, ‘new’, ‘day’](‘A’, ‘new’, ‘day’) |
| D. | Error[‘A’, ‘new’, ‘day’] |
| Answer» B. No outputNo output | |
| 30. |
The output of the snippet of code shown below is: |
| A. | Error |
| B. | [”, ‘n1’, ‘3.1, ‘, ‘n2’, ‘5, ‘, ‘n3’, ‘4.565’] |
| C. | [‘n1’, ‘3.1, ‘, ‘n2’, ‘5, ‘, ‘n3’, ‘4.565’] |
| D. | [‘3.1, ‘, ‘5, ‘, ‘4.565’] |
| Answer» C. [‘n1’, ‘3.1, ‘, ‘n2’, ‘5, ‘, ‘n3’, ‘4.565’] | |
| 31. |
The output of the two codes shown below is the same. State whether true or false. |
| A. | True |
| B. | False |
| C. | May be |
| D. | Can't say |
| Answer» B. False | |
| 32. |
What is the use of “a” in file handling? |
| A. | Read |
| B. | Write |
| C. | Append |
| D. | None of the the mentioned |
| Answer» D. None of the the mentioned | |
| 33. |
What is the output of this program If entered name isCompscibits ? |
| A. | Compscibits |
| B. | Compscibits, Compscibits |
| C. | Comp |
| D. | None of the mentioned |
| Answer» B. Compscibits, Compscibits | |
| 34. |
Which of the following special characters matches a pattern only at the end of the string? |
| A. | \B |
| B. | \X |
| C. | \Z |
| D. | \A |
| Answer» D. \A | |
| 35. |
Correct syntax of file.readlines() is? |
| A. | fileObject.readlines( sizehint ); |
| B. | fileObject.readlines(); |
| C. | fileObject.readlines(sequence) |
| D. | none of the mentioned |
| Answer» B. fileObject.readlines(); | |
| 36. |
To read the next line of the file from a file object infile, we use |
| A. | infile.read(2) |
| B. | infile.read() |
| C. | infile.readline() |
| D. | infile.readlines() |
| Answer» D. infile.readlines() | |
| 37. |
________ matches the start of the string.________ matches the end of the string. |
| A. | ‘^’, ‘$’ |
| B. | ‘$’, ‘^’ |
| C. | ‘$’, ‘?’ |
| D. | ‘?’, ‘^’ |
| Answer» B. ‘$’, ‘^’ | |
| 38. |
Which of the following functions clears the regular expression cache? |
| A. | re.sub() |
| B. | re.pos() |
| C. | re.purge() |
| D. | re.subn() |
| Answer» D. re.subn() | |
| 39. |
Which of the codes shown below results in a match? |
| A. | re.match(‘George(?=Washington)’, ‘George Washington’) |
| B. | re.match(‘George(?=Washington)’, ‘George’) |
| C. | re.match(‘George(?=Washington)’, ‘GeorgeWashington’) |
| D. | re.match(‘George(?=Washington)’, ‘Georgewashington’) |
| Answer» D. re.match(‘George(?=Washington)’, ‘Georgewashington’) | |
| 40. |
Which is/are the basic I/O connections in file? |
| A. | Standard Input |
| B. | Standard Output |
| C. | Standard Errors |
| D. | All of the mentioned |
| Answer» E. | |
| 41. |
Which of the following is not a valid mode to open a file? |
| A. | ab |
| B. | rw |
| C. | r+ |
| D. | w+ |
| Answer» C. r+ | |
| 42. |
Which of the following statements are true ? |
| A. | When you open a file for reading, if the file does not exist, an error occurs |
| B. | When you open a file for writing, if the file does not exist, a new file is created |
| C. | When you open a file for writing, if the file exists, the existing file is overwritten with the new file |
| D. | All of the mentioned |
| Answer» E. | |
| 43. |
Which of the following is not a valid attribute of a file object (fp)? |
| A. | fp.name |
| B. | fp.closed |
| C. | fp.mode |
| D. | fp.size |
| Answer» E. | |
| 44. |
Which of the following special characters represents a comment (that is, the contents of the parenthesis are simply ignores)? |
| A. | (?:…) |
| B. | (?=…) |
| C. | (?!…) |
| D. | (?#…) |
| Answer» E. | |
| 45. |
The special character \B matches the empty string, but only when it is: |
| A. | at the beginning or end of a word |
| B. | not at the beginning or end of a word |
| C. | at the beginning of the word |
| D. | at the end of the word |
| Answer» C. at the beginning of the word | |
| 46. |
Which of the following is supported by awk? |
| A. | if |
| B. | while |
| C. | for |
| D. | if, while, for |
| Answer» E. | |
| 47. |
Which of the following is a built-in function for awk? |
| A. | length |
| B. | index |
| C. | size |
| D. | length and index |
| Answer» B. index | |
| 48. |
The _____ function extracts a substring from a string. |
| A. | length |
| B. | index |
| C. | size |
| D. | substr |
| Answer» E. | |
| 49. |
If a variable is undefined, its value is ____ |
| A. | 0 |
| B. | 1 |
| C. | |
| D. | garbage |
| Answer» B. 1 | |
| 50. |
print statement is necessary for printing a line. |
| A. | True |
| B. | False |
| C. | May be |
| D. | Can't say |
| Answer» C. May be | |