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
natima [27]
4 years ago
12

Write a function isPrime of type int -> bool that returns true if and only if its integer parameter is a prime number. Your f

unction need not behave well if the parameter is negative.

Computers and Technology
1 answer:
PolarNik [594]4 years ago
5 0

Answer:

import math

def isPrime(num):

 

   if num % 2 == 0 and num > 2:

       return False

   for i in range(3, int(math.sqrt(num)) + 1, 2):

       if num % i == 0:

           return False

   return True

Explanation:

The solution is provided in the python programming language, firstly the math class is imported so we can use the square root method. The first if statement checks if the number is even and greater than 2 and returns False since all even numbers except two are not prime numbers.

Then using a for loop on a range (3, int(math.sqrt(num)) + 1, 2), the checks if the number evenly divides through i and returns False otherwise it returns True

see code and output attached

You might be interested in
The Zoom slider will allow users to _____.
NeX [460]
The Zoom slider will allow users to change the way the document appears on the screen
3 0
3 years ago
Read 2 more answers
HURRY IM TIMED Note that common skills are listed toward the top, and less common skills are listed toward the bottom. According
Sloan [31]

Answer:

1 and 3 are the answers

4 0
3 years ago
Read 2 more answers
The query [windows], English (US) has two dominant interpretations: the operating system and the windows in a home.
Flauer [41]

Answer:

B. False

Explanation:

Microsoft Windows is a graphics user interface operating system that uses windows query to search for information in its directory. There are different versions and updates of the windows OS, with latest being window 10 1903. The different version of the windows 10 OS is windows professional, Home, Enterprise etc. As time goes on, more updates will be released for better and advanced security.

3 0
4 years ago
Network architecture is the pattern in which and other devices are set up to communicate. It specifies how from one computer mov
yanalaym [24]

Answer:

1) a.-Computers

b.- cables

c.-switches

2) a.- data

b.- devices

c.- computers

4 0
3 years ago
Can you see what movie you went to on yout credit card history
KatRina [158]
The answer is no
-hope this helped-

3 0
4 years ago
Read 2 more answers
Other questions:
  • Windows uses a memory-management technique known as ________ to monitor which applications you frequently use and preloads them
    15·1 answer
  • Write a pseudocode thats accept and then find out whether the number is divisible by 5 ​
    8·1 answer
  • In two to three sentences, describe how you would move a file.
    6·1 answer
  • Suppose your name was George Gershwin. Write a complete program that would print your last name, followed by a comma, followed b
    11·2 answers
  • What major in Collage is better for a person that wants to learn Javascript and stuff like that? I'm boiling it down to Computer
    14·1 answer
  • Is number 1 correct​
    7·2 answers
  • When the Hyper-V role is added to a Windows Server 2016 server, the hypervisor creates the individual environments, each of whic
    5·1 answer
  • 2. What is software conflict?<br>​
    11·1 answer
  • Create a set of functions that compute the mean, median, and mode of a set of
    8·2 answers
  • ASAP PLS I DON T HAVE ENOUGH TIME
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!