1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
vichka [17]
2 years ago
6

Write a program in python to test if given number is prime or not.

Computers and Technology
2 answers:
Lerok [7]2 years ago
7 0

num = int(input("Enter a number to test if it's prime or not: "))

if num%2 == 0:

   if num == 2:

       print(num,"is prime")

   else:

       print(num,"is not prime")

else:

   count = 0

   for x in range(2,num):

       if num % x == 0:

           count+=1

   if count==0:

       print(num,"is prime")

   else:

       print(num,"is not prime")

I wrote my code in python 3.8. I hope this helps!

Paraphin [41]2 years ago
4 0

Answer:

Answer:

def main():

num = int(input("Input a number to check for prime: "))

if num > 1:

 for i in range(2,num):

  if (num % i) == 0:

   print("%d is not a prime number" % num)

   break

  else:

   print("%d is a prime number" % num)

   break

else:

 print("%d is not a prime number" % num)

 

if __name__ == "__main__":

main()

Explanation:

Solution retrieved from programiz.com.

Note, this program uses the idea of the Sieve of Eratosthenes to validate the input number by using the modulo operator to determine primeness.

The program will output to the user if the number input is indeed prime or not.

Cheers.

Explanation:

You might be interested in
Which type of systems development is characterized by significantly speeding up the design phase and the generation of informati
nydimaria [60]

Answer:

Joint Application Development (JAD)

Explanation:

Joint Application Development is a method of application development that  lay emphasis on the up-front aspect of the application development cycle whereby steady communication between the designers and the intended users of the application under development by coming together in collaborative workshop styled discussions known as JAD sessions involving the mediators, facilitator, observers, end users, experts, and developers. As such with JAD process application development result in fewer errors high quality and is completed in lesser time.

3 0
2 years ago
Each year, Doritos sponsors a Crash the Super Bowl contest, encouraging individuals to submit ads for Doritos to the contest. Th
monitta

Answer:

The answer is creators.

Explanation:

<em>Creators are contributors capable to inovate and share creative ideas. They are not necessarily advertising  and marketing professionals. They can have art, design, music,  and other backgrounds, but the most relevant characteristic of this group of people is their creativity.</em>

<em>They are behind all the great ideas we see at the most relevant social medias nowadays.</em>

7 0
3 years ago
Într-o școală sunt n clase, fiecare având un număr diferit de elevi. Școală primește m pachete cu cărți, fiecare cu un număr dif
Sati [7]

Answer:

Number classes that received pack of books = n classes

Explanation:

Question:

There are n classes in a school, each with a different number of students. The school receives m packs of books, each with a different number of books. For a class to receive a pack, the number of students in that class must be equal to the number of books in the pack. Determine how many classes receive a pack of books.

Solution:

n = number of classes

m = number of pack of books

The above question didn't give the number of students in each class. Neither did it give the number of books in each pack. We would make assumptions in order to derive our answer.

Assumption 1: That the number of pack of books received corresponds to the number of classes in the school.

That is m = n .

Assumption 2:

That the number of students in each class corresponds to the number of books in each packs.

That is, If number of students are: 10, 15,20,25,30.

Each number of books in the each pack would be in that amount: 10, 15,20,25,30.

Since it is stated that for a class to receive a pack, the number of students in that class must be equal to the number of books in the pack.

Hence all classes would receive a

Pack of book based on our assumption.

Number classes that received pack of books = m classes

Note: A change in assumption would change the answer derived. For instance, if m is not equal to m and number of students not equal to number of packs, the answer would be different from the one we obtained above.

7 0
3 years ago
You just bought a new hard drive for your computer to be used as a secondary hard drive to store all your files. After installin
nexus9112 [7]
1) You need to allow the Bios to detect it by changing Input devices in the Bios.
2) Allow Windows to install driver automatically, and your good to go. I have installed an second harddrive to my PC before.
7 0
2 years ago
Read 2 more answers
A router receives a packet and determines the outbound link for the packet. When the packet arrives, 2/3 of one other packet is
vlada-n [284]

Answer:

Queuing Delay is 0.08 seconds

Explanation:

The answer follows a formula that is relatively easy to use and is detailed below.

Queuing Delay = [(L - x) + (nL)] / R

where,

L is packet length given as 3,000 bytes

x is the currently transmitted packet given as 2/3 * 3,000 = 2,000

n is the number of packets waiting in the Que given as 5

R is the rate of transmission given as 4 Mbps (4 * 10^6 Bps)

We can simply plug in the above information in the equation for computing Queuing Delay.

Lets take the numerator first which would be [(3000 - 2000) + (5 * 3000)]

The numerator would be 16000 bytes. These are being transmitted at 4Mbps. So, 16000*4*5 = 320,000 "bits"

Queuing Delay= 320,000/4000000

Queuing Delay = 0.08 seconds.

As we can see, the formula is quite intuitive to use. You are simply taking the number of packets to be transmitting, incorporating the partially transmitted packet, multiplying by the number of packets and the rate of transmission and then dividing the product by the rate of transmission to compute what the delay in the Que is.

6 0
3 years ago
Other questions:
  • The main differences between laptops and desktop computers other than size and portability.
    14·1 answer
  • An is auditor reviewing a network log discovers that an employee ran elevated commands on his/her pc by invoking the task schedu
    10·1 answer
  • This form of analysis is an extension of what-if analysis and is the study of the impact on other variables when one variable is
    8·1 answer
  • While creating a sketch, what helps you identify positive and negative space?
    13·1 answer
  • What is the approximate boiling point
    7·1 answer
  • A label control may be added to a form by double-clicking on the Label control icon in the ________ window.
    15·1 answer
  • 60 POINTS IF YOU GET IT RIGHT
    6·2 answers
  • Which list shows a correct order of mathematical operations that would be used by a spreadsheet formula?
    5·2 answers
  • What is the limitation of computer<br>​
    5·1 answer
  • What component of a change management program includes final testing that the software functions properly
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!