Question

In a program, write a function that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The

python

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def larger_than_n(lst, n):
    print("Number:", n)
    print("List of numbers:")
    print(lst)
    result = []
    for num in lst:
        if num > n:
            result.append(num)
    print("Numbers in list that are larger than {}:".format(n))
    print(result)


larger_than_n([19, 2940, 10, 24, 29, 1, 85, 201, -15, -122, 799], 13)

Number: 13 List of numbers: [19, 2940, 10, 24, 29, 1, 85, 201, -15, -122, 799] Numbers in list that are larger than 13: [19,

Add a comment
Know the answer?
Add Answer to:
python In a program, write a function that accepts two arguments: a list, and a number...
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
  • PYTHON CODE In a program, write a function that accepts two arguments: a list, and a...

    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]

  • Phyton In a program, write a function that accepts two arguments: a list, and a number...

    Phyton 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 smaller than the number n.

  • PYTHON: Using Lists and Arrays! 5. In a program, write a function that accepts two arguments:...

    PYTHON: Using Lists and Arrays! 5. In a program, write a function that accepts two arguments: a list, and a number n. The program should generate 20 random numbers, in the range of 1 through 100, and assign each number to the list. The program should also ask the user to pick a number from 1 through a 100 and assign that number to n. The function should display all of the number in the list that are greater than...

  • Write in C++ program Larger than n In a program, write a function that accepts three...

    Write in C++ program Larger than n In a program, write a function that accepts three arguments: an array, the size of the array, and a number n. Assume the array contains integers. The function should display all of the numbers in the array that are greater than the number n. Input from the keyboard: The filename and path of a list of integer numbers.                                           The number n to test the file numbers. Output to the console: The...

  • in a program, write a function that accepts three arguments: an array, the size of the...

    in a program, write a function that accepts three arguments: an array, the size of the array, and a number n. Assume the array contains integers. The function should display all of the numbers in the array that are greater than the number n.

  • PYTHON QUESTION PLEASE!! Write a function named problem3 that accepts two strings as the arguments, returns...

    PYTHON QUESTION PLEASE!! Write a function named problem3 that accepts two strings as the arguments, returns the characters that occur in both strings. Test case: the arguments are “apple@123” and “banana@#345”, your program should return “a@3”. Write a function named problem3 that accepts two strings as the arguments, returns the characters that occur in both strings. (20 pts) Test case: the arguments are "apple@123” and “banana@#345”, your program should return "a@3".

  • Create a program that will determine the even number(s) from a list of numbers. Your program...

    Create a program that will determine the even number(s) from a list of numbers. Your program should create and call a function FindEven that accepts a list of numbers and returns a list of only the even numbers in sorted order. Note that the original list is given in the starter code. def body(): numberlist = [1, 1000, 5, -3, 2, 16 # Write your code here and notice level # Do NOT include: if __name__ == been provided for...

  • Using Python: write a function that takes two arguments: (1) a target item to find, and...

    Using Python: write a function that takes two arguments: (1) a target item to find, and (2) a list. Your function should return the index (offset from 0) of the last occurrence of the target item or None if the target is not found. E.g. the last occurrence of 33 is at offset 3 in the list [ 42, 33, 21, 33 ] because 42 is offset 0, the first 33 is at offset 1, 21 is offset 2, and...

  • 1. The following program calls the function countLarger that accepts three arguments: an integer array, an...

    1. The following program calls the function countLarger that accepts three arguments: an integer array, an integer size that indicates how many elements are in the array, and an integer n. The function countLarger should return the number of integers in the array that are greater than the value of the argument n. Update the program to include the definition of the function countLarger. #include <iostream> using namespace std; int countLarger(int[], int, int); // Function prototype int main() const int...

  • in python: Write a function, write_file, that expects as arguments, in order: A list of words,...

    in python: Write a function, write_file, that expects as arguments, in order: A list of words, like the one created by the previous function A path to an output file The number of words to write to the output file The seed for the random number generator and writes a randomly-generated file of that many words by randomly selecting words from the list. If you use the random module function random.choice() to select each word from the list, calling the...

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
ADVERTISEMENT