Concept explainers
Question 4
Write a function that will redact every third word in a sentence. Make use of the hashtag (#) symbol to redact the characters that make up the word, i.e. if the word is five characters long then a string of five hashtags should replace that word. However, this should not redact any of the following punctuation marks:
- apostrophes (')
- quotations (")
- full stops (.)
- commas (,)
- exclamations (!)
- question marks (?)
- colons (:)
- semicolons (;)
Arguments:
- sentence (string) →→ sentence that needs to be redacted.
Return:
- redacted sentence (string)→→ every third word should be redacted.
Expected outputs
sentence = "My dear Explorer, do you understand the nature of the given question?" redact_words(sentence) == 'My dear ########, do you ########## the nature ## the given ########?' sentence = "Explorer, this is why you shouldn't come to a test unprepared." redact_words(sentence)=="Explorer, this ## why you #######'# come to # test unprepared."
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images
- Case number three. what is the best way to insert the total_tuition into the FBTEAM vector. This vector is a string but the total_tuition is an integer so it sends an error. How can I store it into a string vector? How do I convert an int into a string? #include "stdafx.h"#include <iostream>#include <cstdlib>#include <ctime>#include <string>#include <vector>#include <cctype>#include <iterator>#include <algorithm>#include <cmath>#include "ConsoleApplication11.h" using namespace std; string FBTeam;string College[5];string location;string Price_of_Ticket;int choice; int main(){vector<string> CULIST(5);vector<string> FBTEAM(5);string itemNumber; int tuition = 0;int dorm = 0;int meal = 0;int total_tuition[5];int average;const int size = 5;double averages[size] = { 0.0 };bool stop = false, itemFound; cout << "--------------------------------------------------------------------------------" << endl;cout << "…arrow_forwardC++ code please: Create a generic functionprint_if(start, stop, condition, out)that prints to output stream out all the elements in the range[start,stop) that satisfy the unary predicate condition. The elements are printed on separate lines. The arguments start and stopare bidirectional iterators. Test your function by printing all the stringsmore than 3 characters long in some vector of stringsarrow_forwardExercise - Collection Functions Using the code below, use the map function to create an array of Int values, whose values are equal to the original integer value, plus 1. Use $0 as you iterate through the values of the array. Print the resulting collection. 5 let testScores = [65, 80, 88, 90, 47] Using the code below, use the filter function to create a new array of String values. The new array should only include Strings longer than four characters. Use $0 as you iterate through the values of the array. Print the resulting collection. Olet schoolSubjects = ["Math" , "Computer Science", "Gym", "English", "Biology"] Using the code below, use the reduce function to subtract all of the values within the array from the starting value 100. Print the resulting value. let damageTaken = [25, 10, 15, 30, 20]arrow_forward
- •is Valid Phone Number(): ReturnsTrue if the provided phone number (represented as a string) is cor-rectly formatted, otherwiseFalse. To be considered correctly formatted, phone numbers must bewritten as###-###-####, where#is a digit between 0 and 9 .•validatePhoneBook(): A phone book is a list where each entry is a phone book record (represented asa dictionary; see below for more details). This function checks each phone book record in the phonebook for correctly formatted phone numbers.A phone book record is a dictionary which initially has two keys: the key"name"mapped to thecontact’s name (string) and the key"phone number"mapped to that contact’s phone number (alsoa string).validatePhoneBook()adds a new key"valid"to the record with the valueTrueif the phonenumber is formatted correctly, otherwiseFalse. 1. Write white-box and black-box tests for the function is ValidPhoneNumber(). You should do this with-out Python, either on paper, or in a simple document. Don’t worry about…arrow_forwardCreate an array of three string values that the fullName variable will use as a point of reference. Make an initialization list for the array using string values for the first, middle, and last names.arrow_forwardCreate an array of three string values that the fullName variable will use as a point of reference. Make an initialization list for the array using string values for the first, middle, and last names.arrow_forward
- Create a JavaScript Arrow function that meets the following requirements: _missingSpace(string)• Authored using arrow expression syntax (constant name _missingSpace)• The function is passed a string argument• The function inserts a white space between every instance of a lowercase character followed immediately by an uppercase character, and returns the modified string, with whitespaces, back to the caller.• Console log output is NOT permitted.• The function should pass each of the illustrated examples below at a minimum._missingSpace(“”) → “”_missingSpace(“a”) → “a”_missingSpace(“A”) → “A”_missingSpace(“Ba”) → “Ba”_missingSpace(“aB”) → “a B”_missingSpace(“BaB”) → “Ba B”_missingSpace(“GeorgeBrownCollege”) → “George Brown College”_missingSpace(“SheWalksToTheBeach”) → “She Walks To The Beach”_missingSpace(“TheGreatUpset”) → “The Great Upset”arrow_forwardCreate a .txt file with 3 rows of various movies data of your choice in the following table format: Movie ID number of viewers rating release year Movie name 0000012211 174 8.4 2017 "Star Wars: The Last Jedi" 0000122110 369 7.9 2017 "Thor: Ragnarok" Create a class Movie which instantiates variables corresponds to the table columns. Implement getters, setters, constructors and toString. ----Important 1. Implement two search methods to search Movies by their rating from unsorted array and by year (first) and a rating (second) from unsorted List. Test your methods and explain their time complexity.arrow_forward4. Complete the function show_upper. This function takes one parameter - a string (s). It should return a string made up of all the upper-case characters in s. For example, if s is “aBdDEfgHijK” then show_upper should return “BDEHK”. It should return the upper-case string - not print it. Do not change anything outside show_upper.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