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 (12th Edition)
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)
- 6. In PHP language, write a program to input a string from the user and print every character of the string in the output separated by the character +. Sample Input: ABCDEF Output: A+B+C+D+E+Farrow_forwardWrite a C/C++ program that takes an input (array) from 1 to n (say n = 50) and displays the string representations of those numbers with following conditions If the current number is divisible by 2, then print CSU If the current number is divisible by 5, then print LB If the current number is divisible by both 2 and 5, then print CSULB If the number is neither divisible by 2 nor 5, then print the number Example: 1 CSU 3 CSU LB CSU 7 CSU 9 CSULB 11 CSU 13 CSU LB CSU 17 CSU 19 CSULB … Tasks to do: (4%) Implement the solution using a single thread (i.e., without using threads and only a main function with any other possible helper function for ease) with all the above conditions implemented in the correct order so that the results are correct. Reason about what can cause the algorithm to print unwanted results (think about the order in which you will write the above…arrow_forwardUsing sys module in Python. Create a program, longest.py, that has a function that takes one string argument and prints a sentence indicating the longest word in that string. If there is more than one word print only the first. Your print statement should read: The longest word is x Where x = the longest word. The word (x) should be all lowercase.arrow_forward
- Give example to remove spaces from a string in python.arrow_forwardUsing Python The Soundex algorithm is used to encode strings. The result of the algorithm is a letter followed by three digits. Similar words will have the same code. For example, Adams and Addams would have the same code. There are several different algorithms for Soundex. Using Python, this online interpreter, and the below listed requirements, create an application that will produce a Soundex-like code based on user-entered string: The first letter of the word is the first letter of the Soundex code. Remove or ignore all letters a, e, i, o, u, h, y, and w. Replace the letters that remain, as follows: Replace this: With this: b, f, p, and v 1 c, g, j, k, q, s, x, and z 2 d and t 3 l 4 m and n 5 R 6 If two or more digits are identical (e.g., 11, 222), only keep the first digit. Choose the first 3 digits, and append to the first letter from Step 1. If you only have 1 or 2 digits, append 0s at the end for the final code.arrow_forwardWrite a C/C++ program that takes an input (array) from 1 to n (say n = 50) and displays the string representations of those numbers with following conditions If the current number is divisible by 2, then print CSU If the current number is divisible by 5, then print LB If the current number is divisible by both 2 and 5, then print CSULB If the number is neither divisible by 2 nor 5, then print the number Example: 1 CSU 3 CSU LB CSU 7 CSU 9 CSULB 11 CSU 13 CSU LB CSU 17 CSU 19 CSULB … Tasks to do: (4%) Implement the solution using a single thread (i.e., without using threads and only a main function with any other possible helper function for ease) with all the above conditions implemented in the correct order so that the results are correct. Reason about what can cause the algorithm to print unwanted results (think about the order in which you will write the above…arrow_forward
- Please help me find the PYTHON CODE for this problem. ASAP! Thank you! What's in the Middle? by CodeChum Admin You already know how to access the middle value of a certain string using index positions, right? Then let's put your learnings to practice. Make a program that shall input a long string that contains an odd number of individual strings separated by comma. Afterwards, input the string that's located in the middle index position. Let's do this. Input A line containing a string separated by a comma. Python,is,fun Output A line containing a string. isarrow_forwardWrite a Python program that takes a String as input from the user, removes the characters at even index and prints the resulting String in uppercase. ===================================================================== Sample Input 1: String Sample Output 1: TIG Explanation: The characters 'S', 'r' and 'n' are at index positions 0, 2, and 4 respectively. Hence they are removed and the remaining characters 'tig' are capitalized giving us output 'TIG'. ===================================================================== Sample Input 2: abcd Sample Output 2: BD =====================================================================arrow_forwardWrite a Python Program to Count Occurrences of a certain Character in a String. The user inputs a string value and the character to search. For example, if the string input value is PHILIPPINES and the character value is P, the output is value 3. There are 3 occurrences of P in the PHILIPPINES. The program must count the same character whether it is in lowercase or uppercase.arrow_forward
- Write a python program with a function that accepts a string as an argument and returns a copy of the string with the first character of each sentence capitalized. For instance, if the argument is “hello. my name is Joe. what is your name?” the function should return the string “Hello. My name is Joe. What is your name?” The program should let the user enter a string and then pass it to the function. The modified string should be displayed. Sample Output: Average number of words per line: 26.0Enter a string for the program to capitalize sentences: hello. my name is Joe. what is your name?Hello. My name is Joe. What is your name?arrow_forwardIN PYTHON: Given a string representing a 10-digit phone number, output the area code, prefix, and line number using the format (800) 555-1212. Ex: If the input is: 8005551212 the output is: (800) 555-1212 Hint: Use string slicing operators. 18005551212 is not allowed.arrow_forwardSlicing in a string is accomplished by specifying a starting and ending position number, and parentheses, to access a particular character. True or false? In python.arrow_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