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]
3 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]3 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
Ann wants to save her presentation so she can work on it later. Which device on her computer can store this data long term?
RUDIKE [14]
I would say that the best option would be a multimedia card.
4 0
3 years ago
Need deveolpers not software
ivolga24 [154]
Developers? For what?
3 0
4 years ago
Read 2 more answers
16. If a user can make modifications to database objects, what permission has that
Vsevolod [243]

B

Explanation:

The Alter command is used when we want to modify a database or object contain in database.

5 0
2 years ago
Assume the method doSomething has been defined as follows: public static void doSomething (int[] values, int p1, int p2) { int t
Dmitriy789 [7]

Answer:

The answer to this question is option "b".

Explanation:

In the method definition, we perform swapping. To perform swapping we define a variable "temp" that swap values of variable p1 and p2 and store in array that is "values". and other options are not correct that can be defined as:

  • In option a, It does not insert any new value in array because we do not pass any value in function.
  • In option c, The function does not copy and assign a value in a new array because in this function we not assign any new array.  
  • In option d, It is incorrect because it can not move an element into high index position.
8 0
3 years ago
Considering current online newspaper editions and the characteristics of digital age media, how do you think newspaper design mi
NeX [460]
One way that a newspaper design may change in the future is that they will only be available in an interactive online edition. The correct answer is B. <span />
6 0
3 years ago
Other questions:
  • Use blank to prevent friends who have been drinking from driving
    14·2 answers
  • The physical address assigned each network adapter is called its ________.
    6·1 answer
  • Which of the following functions does a browser perform?
    7·2 answers
  • Technology offers a variety of rich opportunities available to teachers and students. According to Inan and Lowther (2010), ther
    6·1 answer
  • Often used in connection with a business
    6·1 answer
  • You need to find out how much ram is installed in a system. what command do you execute to launch the system information utility
    12·1 answer
  • A page with no meaningful content that is full of ads and the webmaster makes money from if someone clicks on them is called____
    7·1 answer
  • How a computer encodes text, how it is processed and how computer data is represented.
    6·1 answer
  • How do you increase the number of tries by one?
    10·1 answer
  • The federal communications commission oversees the programming of which entities?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!