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]
3 years ago
6

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

Computers and Technology
2 answers:
Lerok [7]3 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]3 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
Is Bluetooth considered a computing innovation?
Scilla [17]

Answer:

yes it is becauuse through bluetooth i can play cod mobile on my phone wiith my ps4 controller

Explanation:

A Bluetooth device works by using radio waves instead of wires or cables to connect with your cell phone, smartphone or computer. Bluetooth is a wireless short-range communications technology standard found in millions of products we use every day – including headsets, smartphones, laptops and portable speakers.

8 0
3 years ago
A ________ provides quick access to context indicators, email, secure instant messaging, voice and video calling, conference cal
e-lub [12.9K]

Answer:

Universal dashboard

Explanation:

Universal dashboards is a web framework that help people manage their unified communications, providing quick access to context indicators, email, secure instant messaging, voice and video calling, conference calling, corporate RSS feeds, and more. The Mitel Unified Communicator Advanced is a software client that integrates all these features thereby making it possible for employees and co-workers to communicate. This software can also be used to integrate both a company’s ERP and customer relationship management system launching the customer information on the screen any to time a call is been made  such as customer name and location.

5 0
3 years ago
State the difference between IBM PC and apple machintosh computers
azamat

Answer:

a Mac is a PC because PC stands for personal computer. However, in everyday use, the term PC typically refers to a computer running the Windows operating system, not the operating system made by Apple.

7 0
3 years ago
L
Artist 52 [7]

Answer:

I tried, I falid, I sorry :(

Explanation:

......

5 0
3 years ago
Type the correct answer in the box. Spell all words correctly.
mel-nik [20]

Answer:

internet

Explanation:

8 0
3 years ago
Other questions:
  • Consider the folloeing website URL:http://www.briannasblog.com. What does the "http://" represent?
    11·1 answer
  • ANSWER THIS CORRECTLY FOR BRAINLIEST
    13·2 answers
  • If an Administrator performs a clean install of Windows Server 2012 R2 on a new server, and then moves critical domain services
    9·1 answer
  • Which one of the following is the correct code snippet for calculating the largest value in an integer array list aList?
    5·2 answers
  • The system requirements for software include the
    5·1 answer
  • Which UML relationships should be used between a subclass and a superclass? For example, suppose there is an interface or abstra
    5·1 answer
  • Shelly recorded an audio composition for her presentation. Arrange the following steps that Shelly followed in the proper order.
    6·1 answer
  • While organizing his computer's power cords, Matt realizes his printer power cord is frayed (coming apart). What should Matt do
    10·1 answer
  • I WILL GIVE BRAINLIEST
    9·1 answer
  • Question # 2 Multiple Select You wrote a program to compare the portion of drivers who were on the phone. Which statements are t
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!