#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
>>>
Answer:
def someFunc(myList):
# for x in myList:
# print(x)
maximum=max(myList)#finding maximum
element
minimum=min(myList)#finding minimum
element
print(m-n)
input_string = input("Enter a list element separated by space ")#
input is a list of strings
list1 = input_string.split() #splitting every integer into a
list
list1 = [int(i) for i in list1] #converting every string into
number
#print(list1)
someFunc(list1) #passing list to a function
output:



If you have any queries..please comment..Thank you..
#Python 1.Write a function called difference() that accepts a list of numbers from the user and...
Can someone do this python program? Write a function that accepts a list of five numbers from a user and prints the length, sum, average, and largest number of the list.
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”.
IN PYTHON Implement a function called printGreater() that accepts a list of numbers numLst and a number num. The function then iterates through the lst printing all numbers in the list that are greater than num. The results need to be printed on one line. >>> printGreater([200, 45, 270, 3, 7, 1000, 385, 20], 50) 200 270 1000 385 >>> printGreater([], 50) >>>
python In a program, write a function named roll that accepts an integer argument number_of_throws. The function should generate and return a sorted list of number_of_throws random numbers between 1 and 6. The program should prompt the user to enter a positive integer that is sent to the function, and then print the returned list.
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 CODE
In a program, write a function that accepts two arguments: a
list, and a number n. Assume that the list contains numbers. The
function should display all of the numbers in the list that are
greater than the number n. Output should look like:
Number: 5 List of numbers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] List of numbers that are larger than 5: [6, 7, 8, 9, 10]
PYTHON --create a function that accepts a list of numbers and an int that returns index of 2nd occurrence of the int in list, otherwise returns None if # does not repeat more 2 or more times EX: [10,24,3,45,10,49,4,5], 10) returns 4 --create a function that accepts a string that returns true if every letter of the alphabet can be found at least one time in the string, (has to be the lowercase alphabet), and false otherwise. for...
Using PYTHON: (Find the index of the smallest element) Write a function that returns the index of the smallest element in a list of integers. If the number of such elements is greater than 1, return the smallest index. Use the following header: def indexOfSmallestElement(lst): Write a test program that prompts the user to enter a list of numbers, invokes this function to return the index of the smallest element, and displays the index. PLEASE USE LISTS!
PYTHON Implement a function called firstAndLast() that requests a nonempty list from the user and prints the first and last items in the list to the screen with the following messages: >>> firstAndLast() Enter a list: [1,2,3,4,5] The first list element is 1 The last list element is 5 >>> firstAndLast() Enter a list: [[1,2,3], [4,5,6], [7,8,9]] The first list element is [1, 2, 3] The last list element is [7, 8, 9]
1.1. Write a function named "areFirstTwoTheSame AsLast TwoChars" that accepts a string. It returns true if the first two characters and the last two characters of the string are the same. It returns false otherwise. In addition, if the string is empty or has only one character, it also returns false. For example, these are the strings with their expected return values false falsc "AB" true "ABA" false "ABAB" trus "ABBA" false "ABCABC false "ABCCAB" true 1.2 Write a function...