Python Programming: An Introduction to Computer Science, 3rd Ed.
Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
Author: John Zelle
Publisher: Franklin, Beedle & Associates
bartleby

Videos

Question
Book Icon
Chapter 11, Problem 12PE
Program Plan Intro

Modified automated censor program

Program plan:

  • Define the “illegal()” function,
    • Open the input file name in read mode.
    • Create empty list.
    • Create “for” loop to iterate over all the lines.
      • Assign the value with the removed white spaces.
    • Create “for” loop to iterate over list,
      • Print the list element.
      • Check whether the word is equal to list element.
        • If it is “True”, return “True”.
  • Define the “main()” function,
    • Open the input file name in read mode.
    • Open the output file name in write mode.
    • Create “for” loop to iterate over all the lines in a  file,
      • Split the words using “split()” method.
      • Create “for” loop to iterate over all the characters in a word,
        • Check whether the value return from function “illegal()” is “True”,
        • If it is “True”, replace the word with “****”.
          • Join all the words.
          • Print all the lines in output file.
  • Call the “main()” function.

Blurred answer
Students have asked these similar questions
Write a function that finds the number of occurrences of a specified character in a string using the following header:def count(s, ch):The str class has the count method. Implement your method without using the count method. For example, count("Welcome", 'e') returns 2. Write a test program that prompts the user to enter a string followed by a character and displays the number of occurrences of the character in the string.
the string below comes from an alphabet consisting of only characters A and B. Accordingly, write the full code of the program (Use the given space below the question. If you struggle to fit then upload a file) that prints the permutation list that can be formed with the characters A or B, which can replace the question marks, into a text file. (Hint: give a go to into the space recursion) A?AA?BB?A? The output will be like the list below: ABAABBBBAB АВААВВBBAА АBAАВBBAAВ АВААВВBAAА ABAAABBBAB ABAAABBBAA
the string below comes from an alphabet consisting of only characters A and B. Accordingly, write the full code of the program (Use the given space below the question. If you struggle to fit into the space then upload a file) that prints the permutation list that can be formed with the characters A or B, which can replace the question marks, into a text file. (Hìnt: give a go to recursion) А?АА?ВВ?А? tle The output will be like the list below: АВААВВBBAВ ABAABBBBAA АВААВВBAAВ АВААВВBAAА ABAAABBBAB АВАAАВВBAА
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Files & File Systems: Crash Course Computer Science #20; Author: CrashCourse;https://www.youtube.com/watch?v=KN8YgJnShPM;License: Standard YouTube License, CC-BY
UNIX Programming (Part - 10) The File System (Directories and Files Names); Author: ITUTEES;https://www.youtube.com/watch?v=K35faWBhzrw;License: Standard Youtube License