answer.
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
Mumz [18]
2 years ago
14

The is_positive function should return True if the number received is positive, otherwise it returns None. Can you fill in the g

aps to make that happen?
Computers and Technology
2 answers:
poizon [28]2 years ago
8 1
<h2>Question:</h2>

The is_positive function should return True if the number received is positive, otherwise it returns None. Can you fill in the gaps to make that happen?

<em>def is_positive(number):</em>

<em>        if  _____ :</em>

<em>            return _____</em>

<em />

<h2>Answer:</h2>

def is_positive(number):

   if (number > 0):

       return True

  else:

       return "None"

---------------------------------------------------------------------------------

<h2><u>Code Test and Sample Output:</u></h2>

print(is_positive(6))

>> True

print(is_positive(-7))

>> None

<h2></h2><h2> </h2>

----------------------------------------------------------------------------------

<h2><u>Explanation:</u></h2><h2><u></u></h2>

The code above has been written in Python.

Now, let's explain each of the lines of the code;

Line 1: defines a function called <em>is_positive </em>which takes in a parameter <em>number. </em>i.e

<em>def is_positive(number):</em>

<em />

Line 2: checks if the number, supplied as parameter to the function, is positive. A number is positive if it is greater than zero. i.e

<em>if (number > 0):</em>

<em />

Line 3: returns a boolean value <em>True </em> if the number is positive. i.e

<em>return True</em>

<em />

Line 4: defines the beginning of the <em>else</em> block that is executed if the number is not positive. i.e

<em>else:</em>

Line 5: returns a string value "None" if the number is not positive. i.e

<em>return "None"</em>

<em />

All of these put together gives;

===============================

<em>def is_positive(number):</em>

<em>    if (number > 0):</em>

<em>        return True</em>

<em>    else:</em>

<em>        return "None"</em>

<em>================================</em>

An example test of the code has also been given where the function was been called with an argument value of 6 and -7. The results were True and None respectively. i.e

print(is_positive(6))   = True

print(is_positive(-7))  = None

Guest1 year ago
0 0

def is positive number
is number > 0
return True
else :
return False

You might be interested in
How does Accenture help companies harness the power of data to achieve optimal business outcomes?
balandron [24]

Answer:

Accenture Analytics helps organizations realize measurable business value from their data by leveraging a dynamic alliance and vendor ecosystem of leading and emerging technology providers with a technology-agnostic approach to solutions development and delivery.    Hope it help's! :D

4 0
2 years ago
Read 2 more answers
Describe the output when the following code executes in 64-bit mode: .data dividend_hi QWORD 00000108h dividend_lo QWORD 3330002
iragen [17]

Answer:

RAX = 333000h (16 bits with preceding zeros removed)

RDX = 20h (also 16 bits with preceding zeros removed)

Explanation:

The "div" opcode in the assembly language source code is used to divide operands. It accepts a divisor ( the denominator) and divides the content of the AX register. The result is saved in the AX register while the remainder (if any) is saved in the DX register. If the DX register holds any data, the data is replaced with the divisor remnant.

The code above divides the content of the RAX register with the divisor variable and saves the result and remainder in the RAX and RDX respectively.

7 0
2 years ago
Translate each of these statements into logical expressions using predicates, quantifiers, and logical connectives. a) Something
yKpoI14uk [10]

Answer:

Let P(x) = x is in the correct place

Let Q(x) =  x is in the excellent place

R(x) denotes the tool

Explanation:

a) Something is not in the correct place.

P(x) is that x is in the correct place so negation of ¬P(x) will represent x is not in the correct place. ∃x is an existential quantifier used to represent "for some" and depicts something in the given statement. This statement can be translated into logical expression as follows:

                                                    ∃x¬P(x)

b) All tools are in the correct place and are in excellent condition.

R(x) represents the tool, P(x) represents x is in correct place and Q(x) shows x is in excellent place. ∀ is used to show that "all" tools and ∧ is used here because tools are in correct place AND are in excellent condition so it depicts both P(x) and Q(x). This statement can be translated into logical expression as follows:

                                       ∀ x ( R(x) → (P(x) ∧ Q(x))

c) Everything is in the correct place and in excellent condition.

Here P(x) represents correct place and Q(x) represents excellent condition ∀ represent all and here everything. ∧  means that both the P(x) and Q(x) exist. This statement can be translated into logical expression as follows:

                                              ∀ x (P(x) ∧ Q(x)

7 0
2 years ago
in a blank excel workbook go to insert tab on the ribbon, which of the following is Not vailable 1 smart art 2 coloumns ( not co
Anuta_ua [19.1K]

Answer:

  1. hahahahahahahhahah
7 0
2 years ago
What output is produced by the following program segment? Why? (Recall that name.charAt(i) is the i-th character in the string,
vekshin1

Answer:

The output is:

R

M

N

Explanation:

The code snippet print the beginning letter of each word in the given name.

In the for loop snippet:

first the program check if startWord is true and it is true, then it print the value of the character at index 0. Then it check if value of character is empty. If it is empty, startWord is initialized to true else it is initialized to false.

The loop only print a character when the value of i are 0, 8 and 11 which are also the beginning character of a word.

8 0
2 years ago
Other questions:
  • Using Word, Maureen is writing an outline of a presentation she plans to give to her company. She will be showing a video during
    12·2 answers
  • Nick won a $1,000 lottery prize. He can't decide what he should spend the money on. For some time now, he has been planning to b
    5·1 answer
  • A remediation liaison makes sure all personnel are aware of and comply with an organization's policies.
    9·1 answer
  • Why can't you use Friedman's attack on block ciphers?
    12·1 answer
  • A device has an IP address of 10.1.10.186 and a subnet mask of 255.255.255.0. What is true about the network on which this devic
    9·1 answer
  • A _________________________ can use SOAP headers to carry meta information in its messages. A. Web service B. REST Service C. Co
    14·1 answer
  • What statement best describes Konrad Zuse?
    6·2 answers
  • What happened if the offshore team members are not able to participate in the iterations demo due to timezone/infrastructure iss
    12·1 answer
  • Write a multithreaded program that generates the Fibonacci series using Pthreads thread library. This program should work as fol
    10·1 answer
  • Adele’s mother owns a Daycare and she wants to learn all about this business, to help her mom and own it one day. Which CTSO sho
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!