Podcast Beta
Questions and Answers
The function returns the initials of the name represented by first
and last
.
first + '.' + last + '.'
The function returns the first and last letter of the input string.
string[0] + string[-1]
The function returns the word without the first letter.
word[1:]
The function returns the original string with the character at index
replaced by a dash (-).
Signup and view all the answers
The function returns the original string with the character at index
replaced by string2
.
Signup and view all the answers
One of the two lines in the function bad
will cause an error.
Signup and view all the answers
The function returns the length of the input name.
Signup and view all the answers
The function spells the word with a for loop.
Signup and view all the answers
The function returns the count of occurrences of character
in word
.
Signup and view all the answers
The function checks if the word contains any vowels.
Signup and view all the answers
The function returns the input string capitalized and with an exclamation point.
Signup and view all the answers
The function checks if the letter
exists in the name
.
Signup and view all the answers
The function removes all instances of letter
from word
.
Signup and view all the answers
The function removes all instances of letter
from word
, where letter
can be multiple characters.
Signup and view all the answers
What is the source site mentioned?
Signup and view all the answers
Study Notes
Initials
- Function
initials(first, last)
constructs the initials of a name by concatenating the first character offirst
andlast
followed by periods.
Sandwich Sandwiches
- Function
sandwich(string)
returns a new string formed by concatenating the first character and the last character of the input string.
If You're not First, You're Last
- Function
end_of_word(word)
returns a substring that excludes the first letter of the input word.
Part 1, Replace a Letter
- Function
replace_at_index(string, index)
replaces the character at a specified index with a dash (-
) and returns the modified string.
Part 2, Replace a Letter
- Function
replace_at_index(string, index, string2)
replaces the character at a specified index with a new character provided asstring2
.
Find the Error
- An error occurs in an attempt to modify a string's first letter; using
my_string = "H"
incorrectly reassignsmy_string
instead of modifying it.
Length of User's Name
- Function
name_length(name)
returns the length of thename
string using thelen()
function.
Spelling Bee
- Function
spell_word()
iterates through each letter of a specified word and prints it followed by an exclamation mark.
Keeping Count
- Function
count_occurrences(word, character)
counts how many times a specified character appears in a given word, using a counter variable.
Contains a Vowel
- Function
contains_vowel(word)
checks if there are any vowels in theword
by comparing each letter against a predefined list of vowels.
ENTHUSIASM!
- Function
add_enthusiasm(string)
capitalizes the input string and appends an exclamation mark at the end.
What's in a Name?
- Function
name_contains(name, letter)
determines if a specified letter exists in the given name string, returningTrue
orFalse
.
Part 1, Remove All From String
- Function
remove_all_from_string(word, letter)
removes all instances of a specified letter from the given word by continuously searching for it.
Part 2, Remove All From String
- Function
remove_all_from_string(word, letter)
removes all occurrences of a specified substring from the word, adjusting indices accordingly during the search process.
Secret Word Function
- Function
find_secret_word(message)
constructs a hidden word by concatenating uppercase letters from a provided message string.
Source Site
- A resource is available at source site link for further assistance and coding examples.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
This quiz focuses on string manipulation functions as part of the Codehs curriculum. You'll explore how to create initials from first and last names, as well as concatenate the first and last letters of a given string. Test your understanding with these functional examples!