5.24. Functions and Strings Write Code Questions¶
Write a function called
start_athat takes instringas a parameter and returnsTrueif thestringstarts with a lowercase a andFalseotherwise. For example,start_a('apple')should returnTrue.Write a function called
start_athat takes instringas a parameter and returnsTrueif thestringstarts with a lowercase a andFalseotherwise. For example,start_a('apple')should returnTrue.-
Write a function called
square_lengththat takes inareaas 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_semicolonthat takes insentence1andsentence2as parameters and returns both sentences joined by a semicolon with the correct grammar. This means thatsentence1shouldn’t have a terminal punctuation mark, there should be a space after the semicolon, andsentence2should 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 bothsentence1andsentence2are simple and complete sentences with proper grammar.)Write a function called
use_semicolonthat takes insentence1andsentence2as parameters and returns both sentences joined by a semicolon with the correct grammar. This means thatsentence1shouldn’t have a terminal punctuation mark, there should be a space after the semicolon, andsentence2should 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 bothsentence1andsentence2are simple and complete sentences with proper grammar.)-
Write a function called
changethat takes instringas 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_gonethat takes instringas 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_gonethat takes instringas 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’.)