All flashcards
Flashcard 1: What function returns the length of a string in most programming languages?
Answer: length() or len(). Standard method to count characters in a string.
Flashcard 2: Which method checks if a string contains only whitespace in Python?
Answer: isspace(). Checks if all characters are whitespace.
Flashcard 3: Identify the method to capitalize the first character of a string in Python.
Answer: capitalize(). Makes first letter uppercase, rest lowercase.
Flashcard 4: State the method to compare two strings lexicographically in Java.
Answer: compareTo(). Performs alphabetical ordering comparison between strings.
Flashcard 5: Which function creates a string from a list of characters in Python?
Answer: join(). Combines list elements into single string.
Flashcard 6: What function converts a string to a float in Python?
Answer: float(). Converts string to decimal number format.
Flashcard 7: Which method checks if a string is made of alphabetic characters in Python?
Answer: isalpha(). Validates string contains only letter characters.
Flashcard 8: Identify the function that checks if a character is a digit in Python.
Answer: isdigit(). Returns True if character is numeric digit.
Flashcard 9: What function converts an integer to a string in JavaScript?
Answer: toString(). Converts numeric value to string representation.
Flashcard 10: Which method checks the equality of two strings in Java?
Answer: equals(). Compares string content for exact match.
Flashcard 11: Identify the method that formats a string in Python.
Answer: format(). Inserts values into string template placeholders.
Flashcard 12: What function converts a string to a list of characters in Python?
Answer: list(). Creates list with each character as element.
Flashcard 13: Which method can reverse a string in Python?
Answer: slice with [::-1]. Extended slicing with step -1 reverses order.
Flashcard 14: State the method to check if a string ends with a specific sequence in Java.
Answer: endsWith(). Tests if string terminates with given suffix.
Flashcard 15: Which method trims whitespace from both ends of a string in Python?
Answer: strip(). Removes leading and trailing whitespace characters.
Flashcard 16: State the method to get the character at a specific index in C++.
Answer: at() or []. Accesses individual character by position.
Flashcard 17: State the method to replace a substring in a string in Java.
Answer: replace(). Substitutes specified text with new text.
Flashcard 18: Find and correct the error: 'Hello'.substring(0, 3) in Python.
Answer: Correct: 'Hello'[0:3]. Python uses slice notation instead of substring method.
Flashcard 19: Which method splits a string into an array in Python?
Answer: split(). Divides string into array elements by delimiter.
Flashcard 20: What method checks if a string contains a specific substring in JavaScript?
Answer: includes(). Checks if substring exists within the string.
Flashcard 21: What method centers a string with a specified width in Python?
Answer: center(). Pads string with spaces for centered alignment.
Flashcard 22: Which method gets a substring from a string in JavaScript?
Answer: substring(). Extracts portion of string between indices.
Flashcard 23: Identify the method to encode a string to UTF-8 in Python.
Answer: encode('utf-8'). Converts string to UTF-8 byte encoding.
Flashcard 24: What method converts a string to a list of words in Python?
Answer: split(). Breaks string into word array elements.
Flashcard 25: State the method to check if a string is empty in JavaScript.
Answer: length property or === ''. Tests length property or compares to empty.
Flashcard 26: Find and correct the error: 'Hello'.indexOf('e') in Python.
Answer: Correct: 'Hello'.find('e'). Python uses find() instead of indexOf().
Flashcard 27: Identify the method to convert a string to lowercase in Java.
Answer: toLowerCase(). Built-in method for case conversion in Java.
Flashcard 28: Which method concatenates two strings in Python?
Answer: The + operator. Joins strings together using addition operator.
Flashcard 29: State the method to replace a substring in a string in Java.
Answer: replace(). Substitutes specified text with new text.
Flashcard 30: What function returns the length of a string in most programming languages?
Answer: length() or len(). Standard method to count characters in a string.