Starting Out with Python (4th Edition)
4th Edition
ISBN: 9780134444321
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 8.3, Problem 12CP
Explanation of Solution
String modification methods:
- • In Python, the method “lower()” would return a copy of a string with its entire letters converted to lowercase.
- • The method “upper()” would return a copy of a string with its entire letters converted to uppercase.
Syntax:
The syntax for “lower()” method is shown below:
string_variable = ‘string_value’
string_variable.lower()
Explanation:
In the above syntax,
- • The “string_value” denotes string.
- • The “string_variable” denotes variable that references a string...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Assume mystring references a string. Write a statement that uses a slicing expression and displays the first 3 characters in the string.
__________ are spaces that appear at the end of a string. a. Blank spaces b. Secondary spaces c. Ending spaces d. Trailing spaces
Assume the variable name references a String object. Write an if statement that displays “Do I know you?” if the String object contains “Timothy”.
Chapter 8 Solutions
Starting Out with Python (4th Edition)
Ch. 8.1 - Assume the variable name references a string....Ch. 8.1 - What is the index of the first character in a...Ch. 8.1 - If a string has 10 characters, what is the index...Ch. 8.1 - Prob. 4CPCh. 8.1 - Prob. 5CPCh. 8.1 - Prob. 6CPCh. 8.2 - Prob. 7CPCh. 8.2 - Prob. 8CPCh. 8.2 - Prob. 9CPCh. 8.2 - What will the following code display? mystring =...
Ch. 8.3 - Prob. 11CPCh. 8.3 - Prob. 12CPCh. 8.3 - Write an if statement that displays Digit" if the...Ch. 8.3 - What is the output of the following code? ch = 'a'...Ch. 8.3 - Write a loop that asks the user Do you want to...Ch. 8.3 - Prob. 16CPCh. 8.3 - Write a loop that counts the number of uppercase...Ch. 8.3 - Assume the following statement appears in a...Ch. 8.3 - Assume the following statement appears in a...Ch. 8 - This is the first index in a string. a. 1 b. 1 c....Ch. 8 - This is the last index in a string. a. 1 b. 99 c....Ch. 8 - This will happen if you try to use an index that...Ch. 8 - This function returns the length of a string. a....Ch. 8 - This string method returns a copy of the string...Ch. 8 - This string method returns the lowest index in the...Ch. 8 - This operator determines whether one string is...Ch. 8 - This string method returns true if a string...Ch. 8 - This string method returns true if a string...Ch. 8 - This string method returns a copy of the string...Ch. 8 - Once a string is created, it cannot be changed.Ch. 8 - You can use the for loop to iterate over the...Ch. 8 - The isupper method converts a string to all...Ch. 8 - The repetition operator () works with strings as...Ch. 8 - Prob. 5TFCh. 8 - What does the following code display? mystr =...Ch. 8 - What does the following code display? mystr =...Ch. 8 - What will the following code display? mystring =...Ch. 8 - Prob. 4SACh. 8 - What does the following code display? name = 'joe'...Ch. 8 - Assume choice references a string. The following...Ch. 8 - Write a loop that counts the number of space...Ch. 8 - Write a loop that counts the number of digits that...Ch. 8 - Write a loop that counts the number of lowercase...Ch. 8 - Write a function that accepts a string as an...Ch. 8 - Prob. 6AWCh. 8 - Write a function that accepts a string as an...Ch. 8 - Assume mystrinc references a string. Write a...Ch. 8 - Assume mystring references a string. Write a...Ch. 8 - Look at the following statement: mystring =...Ch. 8 - Initials Write a program that gets a string...Ch. 8 - Sum of Digits in a String Write a program that...Ch. 8 - Date Printer Write a program that reads a string...Ch. 8 - Prob. 4PECh. 8 - Alphabetic Telephone Number Translator Many...Ch. 8 - Average Number of Words If you have downloaded the...Ch. 8 - If you have downloaded the source code you will...Ch. 8 - Sentence Capitalizer Write a program with a...Ch. 8 - Prob. 10PECh. 8 - Prob. 11PECh. 8 - Word Separator Write a program that accepts as...Ch. 8 - Pig Latin Write a program that accepts a sentence...Ch. 8 - PowerBall Lottery To play the PowerBall lottery,...Ch. 8 - Gas Prices In the student sample program files for...
Knowledge Booster
Similar questions
- Assume the variable myWord references a string. Write a statement that uses a slicing expression and displays the last 5 characters in the string. What happens if the myWord is less than 5 characters long?arrow_forward_______ means that one string is appended to another.arrow_forwardUsing one of the of a string object, you may determine the location of the substring.arrow_forward
- Write a statement that defines a string variable called city that can hold a string of up to 20 characters.arrow_forwardOne of the string objects may be used to determine where the substring is.arrow_forwardThis string method returns true if a string contains only alphabetic characters and is at least one character in length.a. the isalpha methodb. the alpha methodc. the alphabetic methodd. the isletters methodarrow_forward
- This string method returns true if a string contains only numeric digits and is at least one character in length.a. the digit methodb. the isdigit methodc. the numeric methodd. the isnumber methodarrow_forwardUtilizing an instance of a string object may help you locate the substring.arrow_forwardAssume variable middle_initial has a one-letter string in it.If we also assume this letter is in lower case, which of the following expressions produces the equivalent upper case letter. Select one: a. chr(middle_initial) - 32 b. ord(middle_initial) + 32 c. chr(middle_initial) + 32 d. ord(middle_initial) - 32arrow_forward
- line. Assume that a string variable named myStuff has been declared and contains some string value. Write code to print each individual character to the console, one character to aarrow_forwardc# Danielle, Edward, and Francis are three salespeople at Holiday Homes. Write an application named HomeSales that prompts the user for a salesperson initial (D, E, or F) input as a string. Either uppercase or lowercase initials are valid. While the user does not type Z, continue by prompting for the amount of a sale. Issue the error message "Sorry - invalid salesperson" for any invalid initials entered. Keep a running total of the amounts sold by each salesperson. After the user types Z or z for an initial, display each salesperson’s total, a grand total for all sales, and the name of the salesperson with the highest total unless there is a tie. If there is a tie, indicate this in the program's output with the message: "There was a tie". An example of the program is shown below: Enter a salesperson initial >> D Enter amount of sale >> 10 Enter next salesperson intital or Z to quit >> d Enter amount of sale >> 2 Enter next salesperson intital or Z to quit…arrow_forwardcolor: one of the following strings: 'red', 'blue', 'silver', 'white', 'black'year: year of manufacturing. A number between 1990 and 2018company: one of the following strings: 'Honda', 'Toyota', 'Ford', 'Chevrolet'model: one of the following strings: 'sedan', 'hatchback', 'SUV'Give a logical expression that evaluates to a True or False for a set of cars. e.g. Expression for "Red SUV cars" is (color == "red" and model == "SUV") Give an expression for "Ford sedan cars that are red or blue and were manufactured after 2000"arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT