AP Computer Science Principles Flashcards: Strings

Study Strings in AP Computer Science Principles with focused flashcards that help you recognize the idea, recall the key rule, and apply it in practice-style prompts.

AP Computer Science Principles

Strings

0 mastered0 still learning

0% Complete

QUESTION
1/ 74

Find and correct the error: 'Hello'.indexOf('e') in Python.

Tap card or press Space to flip

ANSWER

Correct: 'Hello'.find('e'). Python uses find() instead of indexOf().

How well did you know it?

Card 1 / 74

What this deck covers

This deck focuses on Strings, giving you a quick way to review the definitions, rules, and examples that matter most for AP Computer Science Principles.

How to use these flashcards

Work through these flashcards in short sessions. Try to answer each prompt before flipping the card, then revisit any cards you miss until the explanation feels automatic.

All flashcards

Flashcard 1: Find and correct the error: 'Hello'.indexOf('e') in Python.

Answer: Correct: 'Hello'.find('e'). Python uses find() instead of indexOf().

Flashcard 2: What method finds a substring's first occurrence in Python?

Answer: find(). Locates initial position of substring occurrence.

Flashcard 3: What method converts a string to uppercase in JavaScript?

Answer: toUpperCase(). Converts all letters to uppercase format.

Flashcard 4: Identify the function that checks if a character is a digit in Python.

Answer: isdigit(). Returns True if character is numeric digit.

Flashcard 5: Which function creates a string from a list of characters in Python?

Answer: join(). Combines list elements into single string.

Flashcard 6: Which method checks the equality of two strings in Java?

Answer: equals(). Compares string content for exact match.

Flashcard 7: What method finds a substring's first occurrence in Python?

Answer: find(). Locates initial position of substring occurrence.

Flashcard 8: 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 9: Identify the method to capitalize the first character of a string in Python.

Answer: capitalize(). Makes first letter uppercase, rest lowercase.

Flashcard 10: What method checks if a string contains a specific substring in JavaScript?

Answer: includes(). Checks if substring exists within the string.

Flashcard 11: Identify the method to encode a string to UTF-8 in Python.

Answer: encode('utf-8'). Converts string to UTF-8 byte encoding.

Flashcard 12: What function converts a string to a float in Python?

Answer: float(). Converts string to decimal number format.

Flashcard 13: What function converts a string to a list of characters in Python?

Answer: list(). Creates list with each character as element.

Flashcard 14: Which method splits a string into an array in Python?

Answer: split(). Divides string into array elements by delimiter.

Flashcard 15: What function converts an integer to a string in JavaScript?

Answer: toString(). Converts numeric value to string representation.

Flashcard 16: State the method to check if a string is empty in JavaScript.

Answer: length property or === ''. Tests length property or compares to empty.

Flashcard 17: 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 18: What method converts a string to a list of words in Python?

Answer: split(). Breaks string into word array elements.

Flashcard 19: What function converts an integer to a string in JavaScript?

Answer: toString(). Converts numeric value to string representation.

Flashcard 20: Identify the method to convert a string to lowercase in Java.

Answer: toLowerCase(). Built-in method for case conversion in Java.

Flashcard 21: State the method to check if a string is empty in JavaScript.

Answer: length property or === ''. Tests length property or compares to empty.

Flashcard 22: Identify the method to capitalize the first character of a string in Python.

Answer: capitalize(). Makes first letter uppercase, rest lowercase.

Flashcard 23: What method converts a string to uppercase in JavaScript?

Answer: toUpperCase(). Converts all letters to uppercase format.

Flashcard 24: Identify the function that checks if a character is a digit in Python.

Answer: isdigit(). Returns True if character is numeric digit.

Flashcard 25: Identify the method to find a substring's last occurrence in Java.

Answer: lastIndexOf(). Finds rightmost position of substring match.

Flashcard 26: What method centers a string with a specified width in Python?

Answer: center(). Pads string with spaces for centered alignment.

Flashcard 27: 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 28: What method converts a string to a float in JavaScript?

Answer: parseFloat(). Converts string to floating-point number.

Flashcard 29: State the method to get the character at a specific index in C++.

Answer: at() or []. Accesses individual character by position.

Flashcard 30: What method converts a string to uppercase in Python?

Answer: upper(). Transforms all letters to capital case.

Flashcard 31: Which method checks the equality of two strings in Java?

Answer: equals(). Compares string content for exact match.

Flashcard 32: Identify the method to find the index of a character in a string in Java.

Answer: indexOf(). Returns position of first occurrence of character.

Flashcard 33: What method centers a string with a specified width in Python?

Answer: center(). Pads string with spaces for centered alignment.

Flashcard 34: Which method concatenates two strings in Python?

Answer: The + operator. Joins strings together using addition operator.

Flashcard 35: State the method to compare two strings lexicographically in Java.

Answer: compareTo(). Performs alphabetical ordering comparison between strings.

Flashcard 36: 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 37: What function converts a string to a list of characters in Python?

Answer: list(). Creates list with each character as element.

Flashcard 38: Which method gets a substring from a string in JavaScript?

Answer: substring(). Extracts portion of string between indices.

Flashcard 39: What method converts a string to a float in JavaScript?

Answer: parseFloat(). Converts string to floating-point number.

Flashcard 40: Which method checks if a string contains only whitespace in Python?

Answer: isspace(). Checks if all characters are whitespace.

Flashcard 41: Identify the method to find a substring's last occurrence in Java.

Answer: lastIndexOf(). Finds rightmost position of substring match.

Flashcard 42: Find and correct the error: 'Java'.charAt(2) in Python.

Answer: Correct: 'Java'[2]. Python uses bracket notation for character access.

Flashcard 43: What function converts a string to an integer in Python?

Answer: int(). Parses string representation into integer value.

Flashcard 44: 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 45: Which function creates a string from a list of characters in Python?

Answer: join(). Combines list elements into single string.

Flashcard 46: What function converts a string to an integer in Python?

Answer: int(). Parses string representation into integer value.

Flashcard 47: Which method checks if a string starts with a specific sequence in Python?

Answer: startswith(). Tests if string begins with given prefix.

Flashcard 48: Identify the method to find the index of a character in a string in Java.

Answer: indexOf(). Returns position of first occurrence of character.

Flashcard 49: Which method can reverse a string in Python?

Answer: slice with [::-1]. Extended slicing with step -1 reverses order.

Flashcard 50: What method checks if a string contains a specific substring in JavaScript?

Answer: includes(). Checks if substring exists within the string.

Flashcard 51: What method converts a string to a list of words in Python?

Answer: split(). Breaks string into word array elements.

Flashcard 52: Which method trims whitespace from both ends of a string in Python?

Answer: strip(). Removes leading and trailing whitespace characters.

Flashcard 53: Which method splits a string into an array in Python?

Answer: split(). Divides string into array elements by delimiter.

Flashcard 54: State the method to replace a substring in a string in Java.

Answer: replace(). Substitutes specified text with new text.

Flashcard 55: Identify the method that formats a string in Python.

Answer: format(). Inserts values into string template placeholders.

Flashcard 56: State the method to get the character at a specific index in C++.

Answer: at() or []. Accesses individual character by position.

Flashcard 57: Identify the method to convert a string to lowercase in Java.

Answer: toLowerCase(). Built-in method for case conversion in Java.

Flashcard 58: State the method to compare two strings lexicographically in Java.

Answer: compareTo(). Performs alphabetical ordering comparison between strings.

Flashcard 59: Identify the method that formats a string in Python.

Answer: format(). Inserts values into string template placeholders.

Flashcard 60: Which method checks if a string contains only whitespace in Python?

Answer: isspace(). Checks if all characters are whitespace.

Flashcard 61: 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 62: Which method concatenates two strings in Python?

Answer: The + operator. Joins strings together using addition operator.

Flashcard 63: Which method checks if a string starts with a specific sequence in Python?

Answer: startswith(). Tests if string begins with given prefix.

Flashcard 64: What function converts a string to a float in Python?

Answer: float(). Converts string to decimal number format.

Flashcard 65: Which method checks if a string is made of alphabetic characters in Python?

Answer: isalpha(). Validates string contains only letter characters.

Flashcard 66: Which method can reverse a string in Python?

Answer: slice with [::-1]. Extended slicing with step -1 reverses order.

Flashcard 67: State the method to replace a substring in a string in Java.

Answer: replace(). Substitutes specified text with new text.

Flashcard 68: What method converts a string to uppercase in Python?

Answer: upper(). Transforms all letters to capital case.

Flashcard 69: Identify the method to encode a string to UTF-8 in Python.

Answer: encode('utf-8'). Converts string to UTF-8 byte encoding.

Flashcard 70: Which method gets a substring from a string in JavaScript?

Answer: substring(). Extracts portion of string between indices.

Flashcard 71: Find and correct the error: 'Hello'.indexOf('e') in Python.

Answer: Correct: 'Hello'.find('e'). Python uses find() instead of indexOf().

Flashcard 72: Which method trims whitespace from both ends of a string in Python?

Answer: strip(). Removes leading and trailing whitespace characters.

Flashcard 73: Find and correct the error: 'Java'.charAt(2) in Python.

Answer: Correct: 'Java'[2]. Python uses bracket notation for character access.

Flashcard 74: Which method checks if a string is made of alphabetic characters in Python?

Answer: isalpha(). Validates string contains only letter characters.