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”.
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"
IN PYTHON 3.7.4 1. Write a function that gets two numbers from the user and returns...
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 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 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 are all the same, and "0" is they are all different. Otherwise, the function returns "-1".
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 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 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 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...
write a c program 14. Write a function that gets two numbers (as parameters) and returns their sum. Write a program that uses the above function to find the sum of the elements in an array contains 10 numbers.
How to write python code that is a dice rolling function that generates random numbers. The dice rolling function takes two arguments: the first argument is the number of sides on the dice and the second argument is the number of dice. The function returns the sum of the random dice rolls. For example, if I call roll dice(6,2) it might return 7, which is the sum of randomly chosen numbers 4 and 3. It somewhere along the lines of:...