subject

A prime number is a number that is only evenly divisible by itself and 1. For example, the number 5 is prime because it can only be evenly divided by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 1, 2, 3, and 6. Write a Boolean function named is_prime which takes an integer as an argument and returns true if the argument is a prime number, or false otherwise. Use the function in a program that prompts the user to enter a number then displays a message indicating whether the number is prime. here is a full explanation
• In order to do this, you will need to write a program containing two functions: • The function main() • The function isprime(arg) which tests the argument (an integer) to see if is Prime or Not.
step1 •
The following is a description of what each function should do: • main() will be designed to do the following: • On the first line you will print out: "My Name’s Prime Number Checker" • You will ask that an integer be typed in from the keyboard. • You will check to be sure that the number (num) is equal to or greater than the integer 2. If it isn’t, you will be asked to re-enter the value. • You will then call the function isprime(num), which is a function which returns a Boolean Value (either True or False). • You will then print out the result that the function returned to the screen, which will be either: • If the function returned True, then print out num "is Prime", or • If the function returned False, then print out num "is Not Prime". • Your entire main() function should be contained in a while loop which asks you, at the end, if you would like to test another number to see if it is Prime. If you type in "y", then the program runs again. • isprime(arg) will be designed to do the following: • It will test the argument sent to it (nuM in this case) to see if it is a Prime Number or not. • The easiest way to do that is to check to be sure that it is not divisible by any number, 2 or greater, which is less than the value of nuM. • As long as the modulo of nuM with any number less than it (but 2 or greater) is not zero, then it will be Prime, otherwise it isn’t. • Return the value True, if it is Prime, or False if it is not Prime.
step 2 • This exercise assumes that you have already written the isprime function, isprime(arg), in Homework-5A. • Write a program called: YourNameHwrk5B. py, that displays all the prime numbers from 2 to whatever integer that you type in. • Your main() function should start by printing your name at the top of the display (e. g. "Charlie Molnar’s Prime Number List") • This program should have a loop that calls the isprime() function, which you include below the function main().

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 08:10
Ihave a music player on my phone. i can buy songs, add them to playlists and play them. obviously it would be redundant to store each song in each playlist; each playlist is just a list of pointers to the songs. for this lab you will simulate this behavior. your program will need to have options to: add songs to the system library (you will store the text of the first line of the song, rather than the audio) add playlists add songs to a playlist list playlists play a playlist list all of the songs in the library with a count of how many times each song has been played remove a song from a playlist remove a playlist remove a song from the library (and thus from all playlists that contain it) note that we will not be checking many error cases. in real programming this would be bad, you should usually try to recognize and respond to as many types of errors as you can. in the context of class we are trying to acquaint you with as many concepts as possible, so for the sake of educational efficiency we will not be checking most errors in this lab, you may assume that your user provides correct input. you may add all appropriate error testing if you wish, but we will not be testing for it.
Answers: 2
question
Computers and Technology, 23.06.2019 02:30
Research data that is presented using descriptive language is said to be
Answers: 2
question
Computers and Technology, 23.06.2019 16:00
What is the biggest difference between section breaks and regular page breaks? section breaks are more difficult to add than page breaks. section breaks make it easier for you to view the document as an outline. section breaks allow you to have areas of the document with different formatting. section breaks are smaller than regular page breaks.
Answers: 2
question
Computers and Technology, 23.06.2019 22:20
If i uninstall nba 2k 19 from my ps4 will my career be gone forever?
Answers: 2
You know the right answer?
A prime number is a number that is only evenly divisible by itself and 1. For example, the number 5...
Questions
question
Mathematics, 25.07.2021 03:40
Questions on the website: 13722361