The Python built-in function str () will convert a numerical argument into a character string representation, and the ‘ + ’ can be used to concatenate strings together. Use these to modify the marathon script to produce cleaner output, for example:
Your speed is 7.74193548387 mph
Your total elapsed time is 46 minutes, 30 seconds
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Additional Engineering Textbook Solutions
Problem Solving with C++ (10th Edition)
Starting Out With Visual Basic (8th Edition)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Introduction To Programming Using Visual Basic (11th Edition)
- PYTHON!!!!! Use the strategy of the decimal to binary conversion implemented in Project 4, and the bit shift left operation defined in Project 5 to code a new encryption algorithm. The algorithm should Add 1 to each character’s numeric ASCII value. Convert it to a bit string. Shift the bits of this string one place to the left. A single-space character in the encrypted string separates the resulting bit strings. An example of the program input and output is shown below: Enter a message: Hello world! 0010011 1001101 1011011 1011011 1100001 000011 1110001 1100001 1100111 1011011 1001011 000101 Program produces correct output given input: Test case: Test for Hello world! Input: Hello world! Results: 0010011 1001101 1011011 1011011 1100001 000011 1110001 1100001 1100111 1011011 1001011 000101 Test case: Test for What a lovely day! Input: What a lovely day! Results: 0110001 1010011 1000101 1101011 000011 1000101 000011 1011011 1100001 1101111 1001101…arrow_forwardWrite a python program that takes a string as an input from the user and then modifies the string in such a way that the string always starts with an uppercase letter and the case of each subsequent letter is the opposite of the previous letter (uppercase character followed by a lowercase character followed by an uppercase character and so on). Finally the modified string is printed to show the user.arrow_forwardWrite a Python program to input a string s and integer i in the range [0, 9].You have to print the count of occurrences of the digit i in the string s.arrow_forward
- Write a python program that accepts a string as input and removes characters from the string which appear more than once. For Example - If input string is - malayalam The output must be - maly Type your answer herearrow_forwardWrite a python program to remove consecutive duplicate characters from a user entered string.arrow_forwardIn python Create a program that will take in an input of ASCII characters and distance value to encrypt and print the result. The program should loop through the length of the string and take the ASCII value to add the distance integer value to it. If the resulting character’s ASCII value is greater than 127, the cipher value should be set to the distance – (127 – ASCII value + 1).arrow_forward
- Write a Python script/code to do the given problems. Create a function that changes specific words into emoticons.Given a sentence as a string, replace the words smile with :)) , grin with :D, sad with :(( and mad with >:(. Example:emotify(“Make me smile”) ➞ Make me :)emotify(“I am mad”) ➞ I am >:arrow_forwardUsing Python, write a program that converts a binary (base 2) number to decimal (base 10). Your program should begin by reading the binary number from the user as a string. Then it should compute the equivalent decimal number by processing each digit in the binary number. Finally, your program should display the equivalent decimal number with an appropriate message.arrow_forwardPython Write a program that accepts a sequence of words separated by whitespace as input to print the words composed of digits only. Sample Input: cat66 dog77 88 hello hi how are you 99bird fi5.55sh Sample Output: cat66 dog77 88 99bird fi5.55sharrow_forward
- Suppose we want to filter a string within a program that outputs similarly to below: Input String to Filter: Transformers Input the char to replace: sInput char to insert (replace with) : *Result: Tran*former* Write Python code that prints out the characters in string str, only with character old_ch replaced with character new_ch, using the following starter code. str = input('Input String to Filter: ')old_ch = input('Intput the char to replace: ')new_ch = input('Input the char to insert (replace with) : ')arrow_forwardWrite a Python program to ask the user to enter two sentences from the user. Then, return a new string made of the second and before the last characters of each input strings Use any String Manipulation Functions presented in Chapter3. Example: Input: Enter the first sentence: My name is Steve Enter the second sentence: I am enrolled in SWE225 Output Y2arrow_forwardUse the strategy of the decimal to binary conversion implemented in Project 4, and the bit shift left operation defined in Project 5 to code a new encryption algorithm. The algorithm should Add 1 to each character’s numeric ASCII value. Convert it to a bit string. Shift the bits of this string one place to the left. A single-space character in the encrypted string separates the resulting bit strings. An example of the program input and output is shown below: Enter a message: Hello world! 0010011 1001101 1011011 1011011 1100001 000011 1110001 1100001 1100111 1011011 1001011 000101arrow_forward
- 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