Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Python program (prime_numbers.py) that checks if a given number is a prime number or not. Your program should repeat asking the user for

Write a Python program (prime_numbers.py) that checks if a given number is a prime number or not. Your program should repeat asking the user for a number, until the user enters a negative number.

Your program should contain two functions:

(1) is_prime(num): This function takes in an int and as parameter, and return True or False. The function tests the int passed to it, if it is a prime number, the function should return True; otherwise, return False. (Submit for 4 points)

(2) __main__: In the main, you should do the following: (Submit for 6 points)

a. Print instruction statement that says: "This program checks if a given number is a prime number"

b. Prompt the user to input a number, int.

c. Check the number entered is not negative and call the function is_prime. Based on the result of is_prime, you program should either "is a prime number" or "is not a prime number".

d. When the user is done, print the following statement "Done. Thanks for using the program!"

Here are some example runs of the program:

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

Optimization And Data Science Trends And Applications 5th Airoyoung Workshop And Airo Phd School 2021 Joint Event

Authors: Adriano Masone ,Veronica Dal Sasso ,Valentina Morandi

1st Edition

3030862887, 978-3030862886

More Books

Students also viewed these Databases questions

Question

What is Centrifugation?

Answered: 1 week ago

Question

To find integral of ?a 2 - x 2

Answered: 1 week ago

Question

To find integral of e 3x sin4x

Answered: 1 week ago

Question

To find the integral of 3x/(x - 1)(x - 2)(x - 3)

Answered: 1 week ago

Question

What are Fatty acids?

Answered: 1 week ago