Question

IN PYTHON 3.7.4 1. Write a function that gets two numbers from the user and returns...

IN PYTHON 3.7.4

1. Write a function that gets two numbers from the user and returns an absolute value of the smaller number. For example, if the user enters -7 and 4, the function returns 7.

2. Write a function that gets two numbers from the user. If the two numbers are consecutive, return “Consecutive”. Otherwise, return “Not Consecutive”.

0 0
Add a comment Improve this question Transcribed image text
Answer #1


def absSmall(n1,n2):
    if(n1<n2):
        return abs(n1)
    else:
        return abs(n2)

def areConsecutive(n1,n2):
    if(abs(n1-n2)==1):
        return "Consecutive"
    else:
        return "Not Consecutive"
Add a comment
Know the answer?
Add Answer to:
IN PYTHON 3.7.4 1. Write a function that gets two numbers from the user and returns...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please use python 3 programming language Write a function that gets a string representing a file...

    Please use python 3 programming language Write a function that gets a string representing a file name and a list. The function writes the content of the list to the file. Each item in the list is written on one line. Name the function WriteList. If all goes well the function returns true, otherwise it returns false. Write another function, RandomRange that takes an integer then it returns a list of length n, where n is an integer passed as...

  • 1) Translate the following equation into a Python assignment statement 2) Write Python code that prints...

    1) Translate the following equation into a Python assignment statement 2) Write Python code that prints PLUS, MINUS, O ZERO, depending on the value stored in a variable named N. 3) What is printed by: 3 - 1 while 5: while 10 Print ) Page 1 of 9 4) Write a Python while loop that reads in integers until the user enters a negative number, then prints the sum of the numbers. 1-2 of 9 4) Write a Python while...

  • Python Assignment: Write a function named AddEm that has two arguments. The function returns the value...

    Python Assignment: Write a function named AddEm that has two arguments. The function returns the value of adding numbers starting from the first arguments, with increments of 1 ending and including the second argument. if 1st argument is less than the second argument use a while loop to generate the return value. Otherwise, return 0

  • For Python: Write a function that receives 3 numbers as arguments and returns “1” if they...

    For Python: Write a function that receives 3 numbers as arguments and returns “1” if they are all the same, and "0" is they are all different. Otherwise, the function returns "-1".

  • Script 1: Sum of Numbers Write a python program that asks the user to enter a...

    Script 1: Sum of Numbers Write a python program that asks the user to enter a series of single-digit numbers with nothing separating them. The program should display the sum of all the single digit numbers in the string. For example, if the user enters 2514, the method should return 12, which is the sum of 2, 5, 1, and 4.

  • 1. use python List to Dictionary Write a function that has three parameters: a list of...

    1. use python List to Dictionary Write a function that has three parameters: a list of unsorted numbers with no duplicates, a start number, and an end number. This function should return a dictionary with all integers between the start and end number (inclusive) as the keys and their respective indices in the list as the value. If the integer is not in the list, the corresponding value would be None. Example unsorted list: [2,1,10,0,4,3] two numbers: 3, 10 returned...

  • Using a Python environment, complete two small Python programs - Write a function which repeatedly reads...

    Using a Python environment, complete two small Python programs - Write a function which repeatedly reads numbers until the user enters “done” Once “done” is entered, print out the sum, average, maximum, and minimum of the values entered If the user enters anything other than a number, detect their mistake using try and except and print an error message and skip to the next number. 2. Write another function so that it draws a sideways tree pointing right; for example,...

  • Python 1 Write a function called sum_odd that takes two parameters, then calculates and returns the...

    Python 1 Write a function called sum_odd that takes two parameters, then calculates and returns the sum of the odd numbers between the two given integers. The sum should include the two given integers, if they are odd. You can assume the arguments will always be positive integers, and the first smaller than or equal to the second. 3 To get full credit on this problem, you must define at least 1 function, use at least 1 loop, and use...

  • #Python 1.Write a function called difference() that accepts a list of numbers from the user and...

    #Python 1.Write a function called difference() that accepts a list of numbers from the user and returns the difference between the largest and the smallest numbers in the list as follows: >>> difference() Please enter a list: [100, 102, 106, -10] 116 >>> difference() Please enter a list: [1,2,3,4,5,6,7,8,9,10] 9 >>>

  • Python Programming Assignment: Write a function to take a string S that returns True if the...

    Python Programming Assignment: Write a function to take a string S that returns True if the letters are in ascending order and False otherwise. To do this go over each letter and check that it is less than the letter that precedes it. Then write a function main that gets one input from the user, then if passing that input to the function above returns True, then show "String is in order", otherwise show " String is unordered".

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT