Example Execution TraceYou must exactly match the below layout.Melcome to a fun word replacement gameEnter the name of the file to use:examplel.txtPlease give a nameMarkPlease give a placeDrexe їPlease give a day of the weekFridayPlease give a timePlease give a verbeatPlease give an animalPlease give a body partmouthHere is your story:Mark is having a party! It's going to be at Drexelon Friday. Please make sure to show up at noon,or else you will be required to eat a/an raccoonwith your mouth

Question
Asked Feb 12, 2019

This question is for Python. Thank you!

Example Execution Trace
You must exactly match the below layout.
Melcome to a fun word replacement game
Enter the name of the file to use:
examplel.txt
Please give a name
Mark
Please give a place
Drexe ї
Please give a day of the week
Friday
Please give a time
Please give a verb
eat
Please give an animal
Please give a body part
mouth
Here is your story:
Mark is having a party! It's going to be at Drexel
on Friday. Please make sure to show up at noon,
or else you will be required to eat a/an raccoon
with your mouth
help_outline

Image Transcriptionclose

Example Execution Trace You must exactly match the below layout. Melcome to a fun word replacement game Enter the name of the file to use: examplel.txt Please give a name Mark Please give a place Drexe ї Please give a day of the week Friday Please give a time Please give a verb eat Please give an animal Please give a body part mouth Here is your story: Mark is having a party! It's going to be at Drexel on Friday. Please make sure to show up at noon, or else you will be required to eat a/an raccoon with your mouth

fullscreen
check_circleExpert Solution
Step 1

The algorithm of the file would be as below:

  1. Receive the inputs as a series of input commands
  2. Concatenate the inputs into sentences as instructed
  3. Open a file object
  4. Write the sentences to the file object (additionally/optionally print the output to console)
  5. Close the file object after writing is complete
Step 2

The above algorithm has been implemented in python as below:

def funprog():

    print(\'what is filename\')

    filename=input()

    print(\'Please give a name\')

    name = input()

    print(\'Please give a place\')

    place = input()

    print(\'Please give a day of the week\')

    dow = input()

    print(\'Please give a time\')

    time = input()

    print(\'Please give a verb\')

    verb = input()

    print(\'Please give an animal\')

    animal = input()

    print(\'Please give a body part\')

    bp = input()

    file = open(filename,\'w\')

    print(\'Here is your story:\')

    file.write(\'Here is your story:\n\')

    print(\'------------------------\')

    file.write(\'------------------------\n\')

  &nb...

fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour*

See Solution
*Response times may vary by subject and question
Tagged in

Engineering

Computer Science

Python

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: Assume the following declarations and initializations (MIN, MAX, num) are made just before each sub-...

A: Since these are separate blocks of code, for the purpose of demonstration we put the blocks in same ...

question_answer

Q: Hi,please I need to use Python for the following: Use for loop to do the following: 1) print the num...

A: Program instructions:Use range() in for loop to print the numbers.Function range() has here argument...

question_answer

Q: Write a program that contains 2 methods, main and printLine (10 points)1) The printLine method will ...

A: Declare required variables ‘first’, ‘second’ and ‘times’ which is used to store first character, sec...

question_answer

Q: Find regular grammars for the following languages on {a, b}: L = {w : na (w) and nb (w) are both eve...

A: Regular grammar for the language L = {W: na (w) and nb (w) are both even} is as follows:

question_answer

Q: 1.6 Compute the scalar cardinality and the fuzzy cardinality for each of thefollowing fuzzy set.

A: The scalar cardinality of a fuzzy set is calculated using the formula:

question_answer

Q: 5-1) (Count positive and negative numbers and compute the average of numbers) Write a program that r...

A: Java program to count posive and negative numbers and computing the total and average of numbers is ...

question_answer

Q: For this program you need to use Eclipse. Carefully read the instructions and write a program that r...

A: Program plan:Class name: EmpPayrollImport the required header files.Define the class "EmpPayroll"Def...

question_answer

Q: Write a GUI application that calculates a car’s gas mileage. The application should let the user ent...

A: Create the MPGCalculator class and declare the given fields along with two JPanel gallonsLabel and m...

question_answer

Q: Financial Application:• Write a program that computes future investment value at a given interest ra...

A: Program plan:Import necessary packages.Define a class named “Main”.Define a method named “computeFut...