Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In mathematics, a positive integer greater than 1, which has no other factors except 1 and the number itself, is called a prime number. 2,

In mathematics, a positive integer greater than 1, which has no other factors except 1 and the number itself, is called a prime number. 2, 3, 5, 7 etc. are prime numbers as they can only be divided by 1 and by themselves to give a whole number. 4, on the other hand is not a prime because, 4 can be divided by 1,2 and 4.

(1 return only)

Thanks a lot.

image text in transcribed
Task 04: In mathematics, a positive integer greater than 1. which has no other factors except 1 and the number itself, is called a prime number. 2, 3, 5, Ir' etc. are prime numbers as they can only be divided by 1 and by themselves to give a whole number. 4, on the other hand is not a prime because, 4 can be divided by 1,2 and 4. Write a function called is _pr:i_me that takes a positive integer called num as parameter and returns True if the number is prime and False otherwise. Ifthe user enters an invalid input [negative integer or decimal number] the tesng program should keep asking the user for another input until the user enters a valid input. Save the function in a PyDev library module named functions.py {same as other questions) Write a main program named tDtI.py that tests the function by asking the user to enter an integer and displaying the output. Sample run Enter a positive integer: B E is not a prime number Sample run Enter a positive integer: -8 Enter a positive integer: 2.5 Enter a positive integer: 23 23 is a prime number I Test your program with3 different numbers: o Prime number o Nonprime number o invalid input that will cause an error message to be displayed I 1I.I"il'hich loop did you use for validating the input? Briefly explain [add the explanation to the docstring of that function] I The input and output are performed in the td.py I Copy the results to testing .txt Note: In the program template, be sure to ll in the le name and the description of the program. Exact naming of les, functions and variable names is critical. Autograding will not work unless you have precisely followed the names given in the assignment document

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

Students also viewed these Programming questions

Question

cite rule 1.5 and 8.4 of ABA model rules of conduct in MLA format

Answered: 1 week ago