5.24. Functions and Strings Write Code Questions¶
Write a function called
start_a
that takes instring
as a parameter and returnsTrue
if thestring
starts with a lowercase a andFalse
otherwise. For example,start_a('apple')
should returnTrue
.Write a function called
start_a
that takes instring
as a parameter and returnsTrue
if thestring
starts with a lowercase a andFalse
otherwise. For example,start_a('apple')
should returnTrue
.-
Write a function called
square_length
that takes inarea
as a parameter and returns"A square with an area of (area) square feet has a side length of (side length) feet."
. The side length is the square root of the area. Usemath.sqrt(area)
to get the square root ofarea
. For example,square_length(36)
should return"A square with an area of 36 square feet has a side length of 6.0 feet."
. Write a function called
use_semicolon
that takes insentence1
andsentence2
as parameters and returns both sentences joined by a semicolon with the correct grammar. This means thatsentence1
shouldn’t have a terminal punctuation mark, there should be a space after the semicolon, andsentence2
should start with a lowercase letter. For example,use_semicolon('The sun is bright.', "Let's go outside.")
should return"The sun is bright; let's go outside."
. (Note: Assume bothsentence1
andsentence2
are simple and complete sentences with proper grammar.)Before you keep reading...
Making great stuff takes time and $$. If you appreciate the book you are reading now and want to keep quality materials free for other students please consider a donation to Runestone Academy. We ask that you consider a $10 donation, but if you can give more thats great, if $10 is too much for your budget we would be happy with whatever you can afford as a show of support.
Write a function called
use_semicolon
that takes insentence1
andsentence2
as parameters and returns both sentences joined by a semicolon with the correct grammar. This means thatsentence1
shouldn’t have a terminal punctuation mark, there should be a space after the semicolon, andsentence2
should start with a lowercase letter. For example,use_semicolon('The sun is bright.', "Let's go outside.")
should return"The sun is bright; let's go outside."
. (Note: Assume bothsentence1
andsentence2
are simple and complete sentences with proper grammar.)-
Write a function called
change
that takes instring
as a parameter and returns a new string with the first two characters uppercased, the last two characters lowercased, and the remaining characters in the middle moved to the front of the string with the first letter capitalized. For example,change('hello')
should return"LHElo"
, andchange('pumpkin')
should return"MpkPUin"
. (Note: Don’t worry about accounting for strings that are 4 characters or less.) Write a function called
first_a_gone
that takes instring
as a parameter and returns a new string without the first lowercase ‘a’. For example,first_a_gone('australia')
should return"ustralia"
. (Note: Don’t worry about accounting for strings that don’t have a lowercase ‘a’.)Write a function called
first_a_gone
that takes instring
as a parameter and returns a new string without the first lowercase ‘a’. For example,first_a_gone('australia')
should return"ustralia"
. (Note: Don’t worry about accounting for strings that don’t have a lowercase ‘a’.)