Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON 1) (25 points) Write a program to read an input file inlines.txt that has normal text, on multiple lines. There are single spaces between

PYTHON image text in transcribed
image text in transcribed
1) (25 points) Write a program to read an input file "inlines.txt" that has normal text, on multiple lines. There are single spaces between words, and each line ends with a n new line character The program should write an output file "outlines.txt" where each word appears on a separate line, ending with a new line character In. Thus if the input file "inlines.tx" contains Here are some lines of input. Please print them with one word per line Don't worry about punctuation the output file would look like Here are some lines of input. Please print them with one Word per line. Don' t Worry about punctuation 2) (25 points) Define a function called sum_and_product (a, b) whose parameters a and b are numbers (possibly with decimal points), which returns two values, the sum of a and b, and the product of a and b. Then write a function that continually asks the user for a pair of numbers with the prompt "Input two numbers, separated by a single space:" until the user enters a blank line by pressing just the enter key. Your program must call the function to determine the sum and product of the two numbers entered. When the user finishes with a blank line, the program should print the average of the sums, and the average of the products. Thus a session should look like: Enter two numbers separated by a single space: 2 3 Enter two numbers separated by a single space: 4 5 Enter two numbers separated by a single space: 1 10 Enter two numbers separated by a single space average sum 8.033333333333333 average product 9.0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions