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
Write a SELECT statement that selects all of the columns for the catalog view that returns information about foreign keys. How m
Nutka1998 [239]

Answer:

SELECT COUNT (DISTICT constraint_name)

FROM apd_schema.constraint_column_usage

RUN

Explanation:

General syntax to return a catalog view of information about foreign keys.

SELECT DISTINCT PARENT_TABLE =

           RIGHT(Replace(DC.constraint_name, 'fkeys_', ''),

           Len(Replace(DC.constraint_name, 'fkeys_', '')) - Charindex('_', Replace(DC.constraint_name, 'fkeys_', ''))),

           CHILD_TABLE = DC.table_name,

           CCU.column_name,

           DC.constraint_name,

           DC.constraint_type

FROM apd_schema.table_constraints DC

INNER JOIN apd_schema.constraint_column_usage CCU

           ON DC.constraint_name = CCU.constraint_name

WHERE  DC.constraint_type LIKE '%foreign'

           OR DC.constraint_type LIKE '%foreign%'

           OR DC.constraint_type LIKE 'foreign%'

RUN

6 0
3 years ago
How does the occupational outlook affect the monetary benefits of a career
Ksivusya [100]
If there are changes to the responsibilities in a career, the typical outcome will change.
4 0
3 years ago
Which of the following would a high school graduate interested in the performing arts most likely do after graduation?
pashok25 [27]

Answer: College

Explanation: I got it right on my quiz

3 0
3 years ago
4013
grigory [225]

Answer:

IM YOUR DADDY

Explanation:

5 0
3 years ago
Read 2 more answers
The term “frivolous” implies that the author
tiny-mole [99]
Thank you for posting your question here at brainly. I hope the answer will help you. Feel free to ask more questions.
believes that the average individual does not need a smart phone 
<span>firivolous mean not serious, light, unimportant.</span>

3 0
3 years ago
Other questions:
  • Drive-by hacking is a computer attack where an attacker accesses a wireless computer network, intercepts data, uses network serv
    5·1 answer
  • Your sister is considering purchasing a tablet computer that utilizes RT as the
    11·1 answer
  • Explain word processing ​
    11·2 answers
  • Green field country is planning to conduct a cricket match between two teams A and B. a large crowd is expected in the stadium a
    6·1 answer
  • What is a Stereo In (&amp; Out) in audio?
    7·1 answer
  • Can you please answer the question in the picture ! :)
    6·1 answer
  • When you login to your blogging account. The first screen with all controls, tools and functions is called .... Select one: a. D
    10·1 answer
  • Which are the 2 main elements that’s make up computer architecture?
    6·2 answers
  • Stephen is looking through some design diagrams created for a specific application. He spots a diagram which uses a parallelogra
    14·1 answer
  • A type of attack where the adversary intercepts network packets, modifies them, and inserts them back into the network is called
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!