Starting Out with Python (4th Edition)
4th Edition
ISBN: 9780134444321
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 8.3, Problem 16CP
Program Plan Intro
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 “upper()” method is shown below:
string_variable = ‘string_value’
string_variable.upper()
Explanation:
In the above syntax,
- • The “string_value” denotes string.
- • The “string_variable” denotes variable that references a string.
- • The “string_variable.upper()” converts the entire string alphabets to upper case characters.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
What will the following code display?
val = 99print('The value is', 'val')
What is this code's purpose?$Error=[] ;
What will the following code display?names = ['Jim', 'Jill', 'John', 'Jasmine']if 'Jasmine' not in names:print('Cannot find Jasmine.')else:print("Jasmine's family:")print(names)
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
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Please draw the correct flowchart for this game ? # Function to display question and answer def new_game(): guesses = [] Right_guesses = 0 question_num = 1 num = 1 for key in questions: print("\n------------------------- \n") print("Question " + str(num) + "\n" ) num += 1 print(key) for i in options[question_num-1]: print(i) guess = input("\nAnswer (A, B, C, or D): ") guess = guess.upper() guesses.append(guess) Right_guesses += check_answer(questions.get(key), guess) question_num += 1 display_score(Right_guesses, guesses) # ------------------------- # Function to check answer def check_answer(answer, guess): if answer == guess: print("\nYour Answer Correct!") return 1 else: print("\nYour Answer Wrong!") return 0 # ------------------------- # Function to display score def display_score(Right_guesses, guesses):…arrow_forwardText-based adventure game: Pretend you are creating a text-based adventure game. At different points in the game, you want the user to select to fight, run, or hide from certain enemies. Modify the application below (week3.py) so that the selection variable is sent as an argument into the choice() function. The user should enter 1 to fight, 2 to run, or 3 to hide in the main(). The choice() function should print one of the three options. You will need to add an if statement in the choice() function to make the correct selection.arrow_forward/ create the following functions: GetInteger - returns an integer DONE GetDouble - returns a double CheckInteger (called from GetInteger) - checks the range of an integer CheckDouble(called from GetDouble) - checks the range of a doubleCalculateSum - overloaded for integers and doubles as parameters DONE CalculateProduct - overloaded for integers and doubles as parameters DONE ShowSums - shows the sums of integers and the sum of doubles ShowProducts - shows the products of integers and the product of doubles. if you can create a function ShowInstructions that passes the type (integer or double) as a string. ShowInstructionsIntegers and ShowInstructionsDoublesarrow_forward
- function phone (inputtext) { var phonenum = /^\d{8}$/; if(inputtext.value.match(phonenum)) { return true; } this script will restrict the user to enter only. . digit phone number. ........ O a. 6 b. 8 с. 9 Od. 10arrow_forwardUsage: mortgagepmt [-s] -r rate [-d downpayment] price In this assignment, you are asked to do a mortgage payment calculation. All information needed for this will be passed to the program on the command line. There will be no user input during the execution of the program. You will need a few pieces of information. The price of the home and the amount of the down payment. You will also need to know the interest rate and the term of the mortgage. To figure your mortgage payment, start by converting your annual interest rate to a monthly interest rate by dividing by 12. Next, add 1 to the monthly rate. Third, multiply the number of years in the term of the mortgage by 12 to calculate the number of monthly payments you’ll make. Fourth, raise the result of 1 plus the monthly rate to the negative power of the number of monthly payments you’ll make. Fifth, subtract that result from 1. Sixth, divide the monthly rate by the result. Last, multiply the result by the amount you want to borrow.…arrow_forwardWhat is the difference between these two statements? void showValues(int num)void showValues(int nums[], int size).arrow_forward
- Complete the get_sum_of_evens (lower_bound, upper_bound) function that takes two integer parameters, lower bound and upper bound. The function returns the sum of all the even numbers between the two bounds, both included, passed to the function. You can assume that lower bound will always be smaller than or equal to upper_bound. For example: Test result get sum_of_evens (2, 4) print("The sum of all even numbers are:", result) print (get_sum_of_evens (9, 17)) Result The sum of all even numbers are: 6 52arrow_forwardComplete the function empty which returns true if s1 has a length of 0. You may not use any library functions from . cstrings.cpp #include using namespace std; bool empty(const char* s) { 1 4 5 7 8 }arrow_forwardComplete the line of code in this program that uses the randint) function? correctAnswer = randint(1,20)arrow_forward
- What will the following code output? int number = 22; int *var = &number; cout << var << endl;arrow_forwarddef division_calculator(a, b): ''' Question 4 You are asked to write a small division calculator, where you are taking 'a' as dividend and 'b' as the divider. You will need to return both the quotient and the remainder. Your returned result should be the: "a is divided by b, with the quotient equals 'quotient' and remainder equals 'remainder'" Note: You must use f-string to do this question. Args: a (int), b (int) Returns: string >>> division_calculator(3, 1) "3 is divided by 1, with the quotient equals 3 and remainder equals 0." ''' # print(division_calculator(9, 3))arrow_forwardIf you attempt to add a double, and an int, the result will be of data typearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education