Question
Asked Oct 13, 2019
15 views

Python 3.7.4

Define a function called signOf that takes a parameter containing an integer value and returns a 1 if the parameter is positive, 0 if the parameter is 0, and -1 if the parameter is negative.

check_circle

Expert Answer

Function definition o...

define function signof ()
def signof (n)
if n is greater than 0
if n 0
#returns 1
return 1
if the number is equal to 0
elif n==0
#retuns 0
return 0
#if the number is not equal to or greater than 0
else
retuns -1
return -1
#calling the function
signof (2)
help_outline

Image Transcriptionclose

define function signof () def signof (n) if n is greater than 0 if n 0 #returns 1 return 1 if the number is equal to 0 elif n==0 #retuns 0 return 0 #if the number is not equal to or greater than 0 else retuns -1 return -1 #calling the function signof (2)

fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Python

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: Write a program in Python for a (very) rudimentary shooter "game". You are the only shooter and you ...

A: NOTE: Sample output is missing in the question. The following program is executed for own sample out...

question_answer

Q: //////////// //////////// //////////// please help me solve this problem in java

A: Program Instructions:Use scanner class object to read the three integers.Create a method names Small...

question_answer

Q: Draw the truth tables for the following Boolean expressions. xy+yz+xz x¯y+yz¯+x¯z (x⊕y)+(y⊕z)+(x...

A:  The logic gates are basically an elementary building block of the digital circuits. Logic gates are...

question_answer

Q: MIPS assembly language please help    Write a program for a grocery store to calculate the total cha...

A: Some definitions required to know before doing this program: -1.What is Mars?2.What is MIPS?3.What i...

question_answer

Q: program5_1.pyWrite a program that uses a custom function to generate a specified number of random in...

A: Program AlgorithmIn the main function, take the input from the user asking for the number of random ...

question_answer

Q: E

A: E) The transition diagram for the given DFA is shown as:

question_answer

Q: How would I go about writing this program?

A: Create a class and get int type data from a user, to print the number of lines on console.Use three ...

question_answer

Q: What was Networking?

A: Networking:Networking, also known as computer networking, is the practice of transporting and exchan...

question_answer

Q: How would I go about writing this program?

A: Program AlgorithmImport the required package and create a class called Pattern.Define the main() and...