Given a positive integer n, assign true to is_prime if n has no factors other than 1 and itself. (remember, m is a factor of n if m divides n evenly.)

Respuesta :

This is the following condition in order to get the specific output for this specific problem: if is_a_prime(n):    is_prime = True Now all you have to do is write is_a_prime().

For the hard code for this problem:

if n == 2:
is_prime = True
elif n % 2 == 0:
is_prime = False
else:
is_prime = True 
for m in range (3, int (n * 0.5) + 1, 2): 
if n % m == 0: 
is_prime = False 
break.
 

To add, a high-level programming language that is widely used for general-purpose programming, created by Guido van Rossum and first released in 1991 is called Python.

Below is the solution of assign true to is_prime if n has no factors other than 1 and itself.

Further explanation

Python is an interpreted, high-level, general-purpose programming language. Python is created by Guido van Rossum and first released in 1991. Its design philosophy emphasizes code readability. Python is a more productive language than Java because it is an interpretive language which is accompanied by elegant syntax and it makes an excellent choice for scripting and rapid application development in many areas. Python is a general-purpose, versatile and popular because it is concise and easy to read, and it is also a good language to have in any programmer’s stack as it can be used for everything such as web development, software development, data science applications.

Given a positive integer n, assign true to is_prime if n has no factors other than 1 and itself. And remember, m is a factor of n if m divides n evenly. So:

if n == 2:

is_prime = True

elif n % 2 == 0:

is_prime = False

else:

is_prime = True

for m in range (3, int(n**0.5)+1, 2):

if n % m == 0:

is_prime = False

Learn more

  1. Learn more about python https://brainly.com/question/4331067
  2. Learn more about python IDLE or similar environment  https://brainly.com/question/6280029
  3. Learn more about python function https://brainly.com/question/9806744

Answer details

Grade:  9

Subject:  mathematics

Chapter:  python

Keywords:  python, integer, factors, python IDLE, is_prime

Q&A Education