Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code: def mycheck(L): flag=True; counter=0; n=len(L); while(flag): if(L[i]%2==0): flag=False; if(counter a[i+1]): flag=False; counter=counter+1; if(counter==n): break; return flag; Python: Write code for function main, which gets

Code:

def mycheck(L): flag=True; counter=0; n=len(L); while(flag): if(L[i]%2==0): flag=False; if(countera[i+1]): flag=False; counter=counter+1; if(counter==n): break; return flag;

Python:

Write code for function main, which gets the user to enter one integer, call it num.

Using error handling, if the entry is not a number, shown an error message.

Check the num is a positive number. If it is, use a for loop to create a list where the for loop runs for num number of times. Each time, ask the user for a number (integer), then add it to the end of a list.

Once the for loop ends, call the mycheck function from the previous question passing it the List, and test its return value: if not true, display some message, else ask the user for a filename and write the list content to the file. When opening the file to write the data open it in writing mode then close it when done.

Call main at the end.

Do not add any comments or code not required by this question. This will cause loss of points.

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

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 2 Lncs 13427

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124251, 978-3031124259

More Books

Students also viewed these Databases questions