Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write a code for Python3 Write code for function main, which does the following: 1. get one integer value from the user. 2. using

Please write a code for Python3 image text in transcribed
Write code for function main, which does the following: 1. get one integer value from the user. 2. using a loop that runs as long as a variable named stop is not 0. The loop gets integers from the user and add those to a list named factors as long! as the user does not enter 0. If the input is O do not ad it to the list and assign variable stop to 0. 3. If the result of passing the input of step 1 and the list of step 2, to function factors is a true value, write all the numbers in the list, each on its own line to a file. Ask the user for the filename. 4. If step 3 results in a false value, print the message "numbers are not factors". 5. Add exception handling to the code above (think of where to place it) so that any error from writing the data to the file are handled by printing the message "data writing failed", otherwise print "data writing succeeded" Call main at the end

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_2

Step: 3

blur-text-image_3

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

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students also viewed these Databases questions

Question

9. Power and politics can be destructive forces in organizations.

Answered: 1 week ago