Blog

MCQs

Disclaimer:

Educational Use Only:

The website links provided are to be used strictly for educational and knowledge-gaining purposes only.

No Misuse:

Do not misuse the links or the information contained therein for any commercial, illegal, or unethical activities.

Respect for Websites and Businesses:

Respect the intellectual property and business interests of the websites and their owners. Do not attempt to alter, copy, or redistribute content without proper authorization.

Acknowledge Value of Knowledge:

Recognize and value the knowledge and resources shared by these websites. Use the information responsibly and ethically.

No Endorsement:

The provision of these links does not imply endorsement of the linked sites, their content, or their products and services. Users are responsible for evaluating the suitability and accuracy of the information.

User Responsibility:

By accessing these links, you agree to use the information at your own risk and to comply with all applicable laws and website terms of use.


Overall MCQs for Reference

  1. Which Python function is used to replace occurrences of a substring with another substring in a string?
    a. substitute()
    b. replace()
    c. change()
    d. swap()
    Answer: b. replace()sanfoundry+1​
  2. What does the strip() method do to a string in Python?
    a. Removes all spaces
    b. Removes leading and trailing whitespace
    c. Converts to lowercase
    d. Splits by whitespace
    Answer: b. Removes leading and trailing whitespacetestbook​
  3. Which method checks if a string is all uppercase?
    a. islower()
    b. isalpha()
    c. isupper()
    d. cap()
    Answer: c. isupper()testbook​
  4. In Python, which operation joins two strings together?
    a. Addition (+)
    b. Multiplication (*)
    c. Division (/)
    d. Subtraction (-)
    Answer: a. Addition (+)csiplearninghub​
  5. Which method counts occurrences of a substring in a string?
    a. count()
    b. find()
    c. sum()
    d. search()
    Answer: a. count()testbook​
  6. What is the output of “hello world”.capitalize()?
    a. Hello World
    b. Hello world
    c. HELLO WORLD
    d. hello World
    Answer: b. Hello worldtestbook​
  7. What does the lower() method do?
    a. Converts string to title case
    b. Converts string to lowercase
    c. Reverses the string
    d. Removes spaces
    Answer: b. Converts string to lowercasetestbook​
  8. Which method would you use to remove specified characters from the start of a string?
    a. strip()
    b. lstrip()
    c. rstrip()
    d. remove()
    Answer: b. lstrip()testbook​
  9. What is the result of “data”[1:3]?
    a. ‘d’
    b. ‘at’
    c. ‘ta’
    d. ‘da’
    Answer: b. ‘at’testbook​
  10. How would you check if all characters in a string are digits?
    a. isalpha()
    b. isdigit()
    c. isnumber()
    d. isinteger()
    Answer: b. isdigit()testbook​
  11. Which command creates a new string object in Python?
    a. str()
    b. string()
    c. new()
    d. create()
    Answer: a. str()csiplearninghub​
  12. What does the split() method do?
    a. Combines strings
    b. Divides a string into a list
    c. Sorts the string
    d. Removes whitespace
    Answer: b. Divides a string into a listtestbook​
  13. Which of these methods joins elements from a list into a single string?
    a. split()
    b. merge()
    c. join()
    d. concat()
    Answer: c. join()testbook​
  14. What will be the output of “Python”.upper()?
    a. python
    b. Python
    c. PYTHON
    d. PyThOn
    Answer: c. PYTHONtestbook​
  15. In string manipulation, what does “immutable” mean?
    a. Cannot be deleted
    b. Cannot be changed after creation
    c. Can be split
    d. Can be joined
    Answer: b. Cannot be changed after creationtestbook​
  16. What does the find() method return if the substring is not found?
    a. -1
    b. 0
    c. None
    d. Error
    Answer: a. -1testbook​
  17. Which function would you use to check if a string starts with a specific substring?
    a. endswith()
    b. startswith()
    c. isprefix()
    d. beginwith()
    Answer: b. startswith()testbook​
  18. In preprocessing for ML, which string operation is commonly used to normalize case?
    a. upper()
    b. lower()
    c. swapcase()
    d. capitalize()
    Answer: b. lower()interviewkickstart+1​
  19. Tokenization in NLP refers to:
    a. Joining strings
    b. Splitting strings into words
    c. Encrypting strings
    d. Formatting strings
    Answer: b. Splitting strings into wordsinterviewkickstart​
  20. What does the method replace(‘a’, ‘A’) do to the string ‘banana’?
    a. Changes all ‘a’ to ‘A’
    b. Changes first ‘a’ to ‘A’
    c. Deletes all ‘a’
    d. No change
    Answer: a. Changes all ‘a’ to ‘A’testbook​
  21. Which encoding method converts text categories to binary columns in ML?
    a. Label encoding
    b. One-hot encoding
    c. Base64 encoding
    d. Index encoding
    Answer: b. One-hot encodingsaidatascience​
  22. Which method would you use for removing stop words in NLP?
    a. remove_words()
    b. delete_stopwords()
    c. stopword()
    d. stop word removal
    Answer: d. stop word removalinterviewkickstart​
  23. What is lemmatization in string preprocessing?
    a. Expanding abbreviations
    b. Reducing words to their root form
    c. Removing punctuation
    d. Changing case
    Answer: b. Reducing words to their root forminterviewkickstart​
  24. Which method ensures text is free from extra spaces before feeding it to a ML model?
    a. replace()
    b. strip()
    c. tokenize()
    d. split()
    Answer: b. strip()testbook​
  25. Given str=”machine”, what is str[::-1]?
    a. error
    b. ‘enihcam’
    c. ‘machine’
    d. ‘enihca’
    Answer: b. ‘enihcam’testbook​
  26. What is the result of “abc”.isalpha()?
    a. True
    b. False
    c. Error
    d. None
    Answer: a. Truetestbook​
  27. What does the rstrip() method do?
    a. Removes whitespace from both ends
    b. Removes whitespace from the right end
    c. Removes whitespace from the left end
    d. Removes whitespace from middle
    Answer: b. Removes whitespace from the right endtestbook​
  28. Which of these functions extracts part of a string?
    a. part()
    b. sub()
    c. slice()
    d. substring()
    Answer: d. substring()sanfoundry​
  29. Which Python library is frequently used for advanced string manipulation in ML preprocessing?
    a. numpy
    b. scikit-learn
    c. pandas
    d. tensorflow
    Answer: c. pandassaidatascience​
  30. In Python, which statement will fail due to string immutability?
    a. str1 = “data”; str1 = “a”sanfoundry​
    b. str1 = “data”; str1.upper()
    c. str1 = “data”; str1 + ” science”
    d. str1 = “data”; str1.replace(“a”, “b”)
    Answer: a. str1 = “data”; str1 = “a”sanfoundry+1​
  31. To remove all instances of a character ‘x’ from a string, which method is used?
    a. delete(‘x’)
    b. remove(‘x’)
    c. replace(‘x’,”)
    d. clean(‘x’)
    Answer: c. replace(‘x’,”)testbook​
  32. Which symbol is used for string concatenation in Python?
    a. +
    b. &
    c. .
    d. –
    Answer: a. +csiplearninghub​
  33. What does “data”.islower() return?
    a. True
    b. False
    c. Error
    d. None
    Answer: a. Truetestbook​
  34. Which function splits a string by specific delimiter in Python?
    a. split()
    b. break()
    c. cut()
    d. delimiter()
    Answer: a. split()testbook​
  35. Which of the following selects a substring from index 2 up to but not including index 5 in ‘abcdef’?
    a. str[2:5]
    b. str[3:5]
    c. str[2:6]
    d. str[2:4]
    Answer: a. str[2:5]testbook​
  36. How do you create a multiline string in Python?
    a. Using triple quotes
    b. Using double quotes
    c. Using single quotes
    d. Using newline characters
    Answer: a. Using triple quotesgeeksforgeeks​
  37. Which method is used to check if a string contains only whitespace?
    a. isspace()
    b. isblank()
    c. isempty()
    d. iswhitespace()
    Answer: a. isspace()testbook​
  38. In text preprocessing, removing punctuation is important for:
    a. Sentence segmentation
    b. Text normalization
    c. Data encryption
    d. Language translation
    Answer: b. Text normalizationinterviewkickstart​
  39. What will be the output of len(“Machine Learning”)?
    a. 16
    b. 17
    c. 18
    d. 15
    Answer: b. 16testbook​
  40. Which of the following functions merges strings with a separator?
    a. join()
    b. concat()
    c. add()
    d. glue()
    Answer: a. join()testbook​
  41. The expression “Hello” * 3 will return:
    a. Error
    b. Hello3
    c. HelloHelloHello
    d. ‘Hello Hello Hello’
    Answer: c. HelloHelloHellotestbook​
  42. Which method converts a string into a list of characters?
    a. list()
    b. split()
    c. array()
    d. chars()
    Answer: a. list()testbook​
  43. What does the partition() method return?
    a. Number of partitions
    b. Tuple with three elements
    c. List of partitions
    d. String
    Answer: b. Tuple with three elementstestbook​
  44. What does swapping case mean for string manipulation?
    a. Changing uppercase to lowercase and vice versa
    b. Removing spaces
    c. Reversing string
    d. Splitting string
    Answer: a. Changing uppercase to lowercase and vice versatestbook​
  45. What is stemming in NLP preprocessing?
    a. Removing suffixes and prefixes from words
    b. Pluralizing words
    c. Changing case
    d. Formatting text
    Answer: a. Removing suffixes and prefixes from wordsinterviewkickstart​
  46. In feature engineering, extracting substrings for ML models can be performed using:
    a. Slicing
    b. Summing
    c. Sorting
    d. Grouping
    Answer: a. Slicingsaidatascience+1​
  47. Which method would you use to pad a string to a specific length?
    a. pad()
    b. rjust()
    c. fill()
    d. empty()
    Answer: b. rjust()testbook​
  48. To check if “ML” exists in “Machine Learning”, what is the valid operation?
    a. “ML” in “Machine Learning”
    b. find(“ML”)
    c. index(“ML”)
    d. search(“ML”)
    Answer: a. “ML” in “Machine Learning”csiplearninghub​
  49. Which function would you use to remove duplicates in sentences while cleaning textual data?
    a. unique()
    b. drop_duplicates()
    c. duplicated()
    d. none()
    Answer: c. duplicated()saidatascience​
  50. Which method converts the first character of the string to uppercase and the rest to lowercase?
    a. capitalize()
    b. title()
    c. upper()
    d. format()
    Answer: a. capitalize()testbook​
  1. https://www.sanfoundry.com/arduino-questions-answers-string-manipulation/
  2. https://testbook.com/objective-questions/mcq-on-string-data-type–60014612a1f01e033fa34694
  3. https://csiplearninghub.com/mcq-on-python-string-class-11/
  4. https://interviewkickstart.com/blogs/learn/data-preprocessing-techniques-clean-ml-data
  5. https://saidatascience.com/data-handling-and-preprocessing/
  6. https://www.geeksforgeeks.org/quizzes/python-string-quiz/
  7. https://www.scribd.com/document/787082322/MCQ-Strings-Gr-10
  8. https://www.sanfoundry.com/c-multiple-choice-questions-answers-string-operations/
  9. https://www.sanfoundry.com/python-multiple-choice-questions-answers/
  10. https://www.geeksforgeeks.org/quizzes/string-data-structure-quiz-for-beginners/
  11. https://www.vedantu.com/cbse/important-questions-class-11-computer-science-chapter-8
  12. https://pynative.com/python-string-quiz/
  13. https://www.gyansetu.in/blog/machine-learning-mcq-interview-preparation/
  14. https://diptisurvase.wordpress.com/wp-content/uploads/2022/09/ml-mcqs.pdf
  15. https://www.scribd.com/document/438379541/Mcq
  16. https://www.aionlinecourse.com/ai-quiz-questions/natural-language-processing/text-preprocessing
  17. https://www.examveda.com/java-program/practice-mcq-question-on-strings/
  18. https://www.sanfoundry.com/data-preprocessing-ml-cleaning-normalization-encoding/
  19. https://www.interviewbit.com/data-structure-mcq/
  20. https://www.igmguru.com/blog/machine-learning-mcqs

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!