Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Write a function repeatPhrase(phrase, n), which prints the given phrase n times, alternating between lowercase and uppercase. Recall, that if a String is a string, then a.upper() is the uppercase of that string, and a.lower() is the lower case of the string. For example, repeat('The sky is yellow', 5) would print:
the sky is yellow
THE SKY IS YELLOW the sky is yellow
THE SKY IS YELLOW the sky is yellow
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 4 steps with 2 images
Knowledge Booster
Similar questions
- Write a function to determine whether a string is a permutation of a palindrome given a string. A word or phrase that reads the same both forward and backward is known as a palindrome. Letters are rearranged in a permutation. The palindrome need not contain only words from dictionaries. EXAMPLEInput: Tact CoaOutput: True (permutations: "taco cat'; "atco eta·; etc.)arrow_forwardWrite a function print_shampoo_instructions() with parameter num_cycles. If num_cycles is less than 1, print "Too few.". If more than 4, print "Too many.". Else, print "N : Lather and rinse." num_cycles times, where N is the cycle number, followed by "Done.".Sample output with input: 2 1: Lather and rinse. 2: Lather and rinse. Done. Hint: Define and use a loop variable. I am getting the correct output,but i can't get rid of the white space between the number and the ':' 1 : Lather and rinse. 2 : Lather and rinse. Done.arrow_forwardCreate a function that takes a string and returns the number of alphanumeric characters that occur more than once. Examples duplicateCount("abcde") duplicateCount("aabbcde") → 2 duplicateCount("Indivisibilities") - duplicateCount("Aa") 0 // Case sensitive Narrow_forward
- Write a Python program which asks the user for a series of strings as input, and stores each entered string. The user signals the end of input by typing quit. Please implement the following: text_get() This function does the job of repeatedly asking the user for text to input. Before the function finishes, it must combines all the strings entered into one string, and return that string. main() The only purpose of this function is to call text_get() and print the returned string. Do not use the eval function.arrow_forwardWrite a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. For example, if str = "There", then after removing all the vowels, str = "Thr". After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel. I am at a loss with this prompt ^^, here's my code. Any help is appreciatedarrow_forwardWrite a function to pig_latin that converts a word into pig latin, by: 1. Removing the first character from the start of the string, 2. Adding the first character to the end of the string, 3. Adding "ay" to the end of the string. So, for example, this function converts "hello" to "ellohay". Call the function twice to demonstrate the behavior. There is a worked example for this kind of problem.arrow_forward
- Can u code it in Pythonarrow_forwardpython help... Write a function justVowels() that takes a string as a parameter and returns a new string that contains all the vowels found in the parameter string. The vowels in the returned string should appear in the same order as they did in the parameter string. A vowel is one of a, e, i, o, or u. both the upper- and lower-case vowels should be included. The characters in the returned string should have the same capitalization as they did in the parameter string. If the function is given a string without any vowels or an empty string, it should return the empty string. Use the if-else condition with iterate loop pattern. Don’t forget to include the docstring and comments. How it should run... >>> justVowels('Did you include your collaboration statement') 'iouiueouoaoaioaee' >>> justVowels('If you did not include your collaboration statement no points') 'Iouioiueouoaoaioaeeooi' >>> justVowels('1,2,3,4,...') '' >>> justVowels('') ''arrow_forwardWrite a function named encode_string(sentence) that takes a string value as its input and returns an encoded string, where each character of the input string is replaced by its ASCII code plus 3 values. Whitespace characters should not be encoded. For example, if the function was passed the input string: Hello World then it should return: Khoor Zruog For example: Test sentence "Hello World" print (encode_string(sentence)) Result Khoor Zruogarrow_forward
- Write a program that inputs a student's name in the following form: lastName, firstName middleName. The program will convert the name to the following form: firstName middleName lastName. Your program must read the student's entire name in one variable and must consist of a user-defined function that takes as input a string, consisting of a student's name, and returns the string consisting of the altered name. You can use the string function find to find the index of ,(the comma); the function length to find the length of the string; and the function substr to extract the firstName, middleName, and lastName.arrow_forwardWrite out a function that prints out all the permutations of a string. For example, abc would give you abc, acb, bac, bca, cab, cba.arrow_forwardWrite a function sum(x,y) that returns a string indicating what the sum of x and y is. For example, when x=3 and y=17 your function should return the string 'The sum of 3 and 17 is 20.'arrow_forward
arrow_back_ios
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