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
KonstantinChe [14]
3 years ago
9

Define a function is_prime that receives an integer argument and returns true if the argument is a prime number and otherwise re

turns false. (An integer is prime if it is greater than 1 and cannot be divided evenly [with no remainder] other than by itself and one. For example, 15 is not prime because it can be divided by 3 or 5 with no remainder. 13 is prime because only 1 and 13 divide it with no remainder.) This function may be written with a for loop, a while loop or using recursion. Use the up or down arrow keys to change the height.
Computers and Technology
1 answer:
qaws [65]3 years ago
5 0

Answer:

<em>This function (along with the main)is written using python progrmming language.</em>

<em>The function is written using for loop; </em>

<em>This program does not make use comments (See explanation section for detailed line by line explanation)</em>

<em></em>

def is_prime(num):

    if num == 1:

         print(str(num)+" is not prime")

    else:

         for i in range(2 , num):

              if num % i == 0:

                   print(str(num)+" is not prime because it can b divided by "+str(i)+" and "+str(int(num/i))+" with no remainder")

                   break;

         else:

              print(str(num) + " is prime because only 1 and "+str(num)+" divide it with no remainder")

num = int(input("Number: "))

is_prime(num)

Explanation:

This line defines the function is_prime

def is_prime(num):

The italicize line checks if the user input is 1; If yes it prints 1 is not prime

<em>     if num == 1: </em>

<em>          print(str(num)+" is not prime") </em>

If the above conditional statement is not true (i.e. if user input is greater than 1), the following is executed

    else:

The italicized checks if user input is primer (by using for loop iteration which starts from 2 and ends at the input number)

         <em>for i in range(2 , num): </em>

<em>               if num % i == 0: </em>

<em>This line prints if the number is not a prime number and why it's not a prime number</em>

<em>                    print(str(num)+" is not prime because it can b divided by "+str(i)+" and "+str(int(num/i))+" with no remainder") </em>

<em>                    break; </em>

If otherwise; i.e if user input is prime, the following italicized statements are executed

         <em>else: </em>

<em>               print(str(num) + " is prime because only 1 and "+str(num)+" divide it with no remainder") </em>

<em>The function ends here</em>

The main begins here

num = int(input("Number: "))  This line prompts user for input

is_prime(num) This line calls the defined function

You might be interested in
Define function print_popcorn_time() with parameter bag_ounces. If bag_ounces is less than 3, print "Too small". If greater than
Oxana [17]

Answer:

def print_popcorn_time(bag_ounces):

 if bag_ounces<3:

    print("Too Small")

 elif bag_ounces>10:

   print("Too Large")

 else:

   total = 6*bag_ounces

   print('{} seconds'.format(total))

Explanation:

Using Python programming language

The function is defined to accept a single parameter

Using a combination of if/elif/else statements, the approprite message is displayed when the function is called

6 0
3 years ago
Switches: Select one:
const2013 [10]

Answer:

b. connect two or more network segments that use different data link protocols

Explanation:

A switch is an analog device that allows to interconnect networks, it is possibly one of the devices with a higher level of scalability. It is important to clarify that a Switch does not only provide connectivity with other networks, nor does it provide connectivity with the Internet, for this purpose a router is necessary.  

6 0
4 years ago
O How basic blocks are identified and how the blocks are used to construct control flow graphs
OLEGan [10]

Basic blocks are identified  because they are known to be a straight line that is known also as a code sequence that tends to have no branches in regards to its in and out branches and its exception is only to the entry and at the end.

Note that  Basic Block is said to be a composition  of statements that is known to be one that often always executes one after other, and this is often done in a sequence.

<h3>How do you create a flow graph from the basic blocks?</h3>

Flow graph  is gotten by:

  • Lets Block B1 be the initial node and also Block B2 will tend to follows B1, so from B2 to B1 there is seen a kind of an edge.

Note that the first task is for a person to partition a sequence of three-address code and this is done into basic blocks.

Hence, Basic blocks are identified  because they are known to be a straight line that is known also as a code sequence that tends to have no branches in regards to its in and out branches and its exception is only to the entry and at the end.

Learn more about basic blocks from

brainly.com/question/132319

#SPJ1

5 0
2 years ago
द्विआधार जोड गर (Binary<br>addition):<br>-<br>(i) 1012 + 1112<br>(ii) 1112 + 100​
fenix001 [56]

Answer:

1.2124

2.1212 is the correct answer right

4 0
3 years ago
A customer has several small branches and wants to deploy a Wi-Fi solution with local management using CAPWAP. Which deployment
mash [69]

Answer:

Mobility express

Explanation:

Mobility express is defined as the ability to use the access point or the AP as a controller. It related to the lightweight network which is without a controller box. The access point of the mobility express uses CAPWAP images.

The CAPWAP stands for Control And Provisioning of Wireless Access Points. It is standard protocol which allows a central wireless of LAN access controller to use and manage the wireless access points.

Thus a customer who has various small branches and wishes to deploy a Wi-fi solution with the local management using CAPWAP should use the Mobility express as the deployment model.

6 0
3 years ago
Other questions:
  • A banker would like to present a spreadsheet as part of a presentation to potential clients. The spreadsheet makes use of severa
    14·1 answer
  • Computers are said to use binary data because all computer data is simply a series of Os and 1s.
    10·1 answer
  • Your brother is starting 9th grade next year and is thinking about going to college. What step would you recommend he take?
    14·1 answer
  • Which OS function does a CLI fulfill? A User interface B Running applications C Hardware interface D Booting
    8·1 answer
  • FRee points just put something
    14·2 answers
  • Portable Document Format (PDF) is a file format that provides an electronic image of a document and can be viewed, printed, and
    12·2 answers
  • To extract detailed and comprehensive responses from your client, use the _____ questioning technique.
    5·2 answers
  • Selma writes the following four answers in her Computer Science examination.
    8·2 answers
  • What is the function of HTML?
    6·2 answers
  • What starts with p and ends with orn
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!