Python please  prime_test.py: def is_prime(num): #ADD CODE to return True if num is prime; False if not def main(): #ADD CODE to call is_prime() for integers 1-100 # and print the ones that are prime main()

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 10PE
icon
Related questions
Question

Python please 

prime_test.py:

def is_prime(num):
#ADD CODE to return True if num is prime; False if not
def main():
#ADD CODE to call is_prime() for integers 1-100
# and print the ones that are prime
main()

Prime numbers: A prime number is a number that is evenly divisible only by itself and
one. For example, 3 is a prime becuase it can only be evenly divided by 1 and 3. The
number 4 is not prime because it can be divided evenly by 2. Twenty-one (21) is not prime
because it can be divided evenly by 3 and 7. The first five prime numbers are: 2,3,5,7,11
Starting with the provided starter-file prime_test.py, write a function is_prime() that
takes an interget argument and returns True if the interger is prime, False otherwise.
It does not print anything(Note: You can have is prime() print things while you are
developing it and debugging it. But deleteing or comment_out print statements in this
function before submitting your code.)
Write a main() function that displays a list of prime numbers between 1 and 100
inclusive, as shown below. It calls is_prime(n) to determine if an interget is prime. It
should also write then same output to an output file primes.txt.Everytime it runs, the
program should replace whatever was in the output file.
Example:
The prime numbers from 1 to 100 are:
2
3'
7
11
Transcribed Image Text:Prime numbers: A prime number is a number that is evenly divisible only by itself and one. For example, 3 is a prime becuase it can only be evenly divided by 1 and 3. The number 4 is not prime because it can be divided evenly by 2. Twenty-one (21) is not prime because it can be divided evenly by 3 and 7. The first five prime numbers are: 2,3,5,7,11 Starting with the provided starter-file prime_test.py, write a function is_prime() that takes an interget argument and returns True if the interger is prime, False otherwise. It does not print anything(Note: You can have is prime() print things while you are developing it and debugging it. But deleteing or comment_out print statements in this function before submitting your code.) Write a main() function that displays a list of prime numbers between 1 and 100 inclusive, as shown below. It calls is_prime(n) to determine if an interget is prime. It should also write then same output to an output file primes.txt.Everytime it runs, the program should replace whatever was in the output file. Example: The prime numbers from 1 to 100 are: 2 3' 7 11
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning