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
Which is an unethical use of technology and resources at the workplace?
Greeley [361]
The answer is B. sharing a coworker’s performance scores with your colleagues
6 0
3 years ago
Read 2 more answers
What cell phone technology is the most popular in the united states?
Alchen [17]
IPhone and Android. ....
3 0
3 years ago
Read 2 more answers
True / False<br> The exponent in floating point is stored as a biased value.
horrorfan [7]

Answer:

True

Explanation:

The bias value present in a floating point number deals with the positiveness and negativeness of the exponent part for a floating point number.  The bias value for a floating point number is 127. It means that 127 is always needed to be added to the exponent part of any floating point number.

In a single precision floating point number, we need 8 bits to store the exponent. Rather than storing it as a signed two's complement number, it is easier to simply add 127 to the exponent (because the lowest value that can be in 8 bit signed is -127) and simply store it as an unsigned number. If the stored value is bigger than the bias then it would mean the value of the exponent is positive otherwise it is negative, but if they are equal then it is 0.

4 0
4 years ago
The following slide was created as part of a presentation that trains new employees how to use the scheduling and calendar softw
brilliants [131]

it has animation, but it does not have multimedia and only has text and no images

8 0
3 years ago
Read 2 more answers
The I/O modules take care of data movement between main memory and a particular device interface.A. TrueB. False
just olya [345]

Answer:

A: True

Explanation: hiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii

8 0
3 years ago
Other questions:
  • Which of the following would be a tradeoff of a scientific advancement that enables us to catch fish from the ocean faster than
    5·1 answer
  • It is an attribute that must be used in the form tag in specifying an input file type
    9·1 answer
  • State two functions of windows environment​
    9·1 answer
  • A parent is browsing through a shopping website, looking for blue-colored striped socks for her child. She is fine if the socks
    15·1 answer
  • Implement the RC4 stream cipher in C++. User should be able to enter any key that is 5 bytes to 32 bytes long. Be sure to discar
    7·1 answer
  • Random number between 0 and 5 (inclusive)
    10·2 answers
  • Testing a function or program using test values that are at or near the values that change the outcome of the program is known a
    13·1 answer
  • Consider the code below. When you run this program, what is the output if the temperature is 77.3 degrees Fahrenheit?
    6·1 answer
  • _____ describes the layout of the screen. Block-based, Interface, Editor, Player
    11·2 answers
  • k-means clustering cannot be used to perform hierarchical clustering as it requires k (number of clusters) as an input parameter
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!