Question

Using PyCharm, under lab8, under Directory exercise, create a Python file called more_loops.py. Write a function, nbrs_greate

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

The answer to this question is as follows:

The code is as follows:

def nbrs_greater(list1,list2):
result=[]
for i in list1:
count=0
for j in list2:
if(j>i):
count+=1
result.append(count)
return result

print(nbrs_greater([20,5,1,6],[1,4,8,12,16]))
  

The input and output are provided in the screenshot below:

1 - def nbrs_greater (listi,list2): 2 result=[] 3 for i in listi: 4 count=0 5 - for j in list2: if(j>i): 7 count+=1 8 result.

Add a comment
Know the answer?
Add Answer to:
Using PyCharm, under lab8, under Directory exercise, create a Python file called more_loops.py. Write a function,...
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
  • Create a new Python program in IDLE, and save it as lab8.py.(Again, I recommend saving lab...

    Create a new Python program in IDLE, and save it as lab8.py.(Again, I recommend saving lab progranms Your Python program will do the following: Create an empty list . Use a for loop to ask the user for 10 numbers. Add each number to your list using the append metha . Use another for loop to print the list in reverse order, one per line . Use a while loop to count how many positive numbers are in the list...

  • Create a class called Lab7b and in it implement all of the methods below. Also, write...

    Create a class called Lab7b and in it implement all of the methods below. Also, write a main method with test calls to all of these methods. Don’t forget to turn in your file to Canvas before the end of the lab today. int[][] random(int N, int start, int end) returns an N-by-N matrix of random integers ranging from start to end; int rowSum(int[][] a, int i) returns the sum of the elements in row i of the 2-D array...

  • CSC 130 Lab Assignment 8 – Program Menu Create a C source code file named lab8.c...

    CSC 130 Lab Assignment 8 – Program Menu Create a C source code file named lab8.c that implements the following features. Implement this program in stages using stepwise refinement to ensure that it will compile and run as you go. This makes it much easier to debug and understand. This program presents the user a menu of operations that it can perform. The choices are listed and a prompt waits for the user to select a choice by entering a...

  • Exercise 3: Work exercise 11.4, 11.12, and 11.14 into one program (to develop 3 methods for...

    Exercise 3: Work exercise 11.4, 11.12, and 11.14 into one program (to develop 3 methods for ArrayList: first method finds the maximum element in an array list; the second method computes the sum of all elements in an array list; and the third method combines (union) two lists by adding the second list to the first list). Use Integer type for all methods. See problem statements for methods signatures and sample test data. Write one separate test program to test...

  • In PYTHON! Exercise 3: Lists and Functions In this exercise we will explore the use of...

    In PYTHON! Exercise 3: Lists and Functions In this exercise we will explore the use of lists and functions with multiple inputs and multiple outputs. Your task is to implement the separate_and_sort function. This function takes two input parameters: 1. A list containing strings and integers in any order. 2. An optional integer parameter size which controls how many items in the list the function will process. If the length of the list is smaller than the value of size,...

  • urgent Help needed in python program ! Thanx # This is a function definition. You can...

    urgent Help needed in python program ! Thanx # This is a function definition. You can ignore this for now. def parse_integer_list_from_string(string): """ Returns a list of integers from a string containing integers separated by spaces. """ # Split the line into a list of strings, each containing a number. number_string_list = string.split() # Create an empty list to store the numbers as integers. numbers = [] # Convert each string to an integer and add it to the list...

  • Write a python program (recursive.py) that contains a main() function. The main() should test the following...

    Write a python program (recursive.py) that contains a main() function. The main() should test the following functions by calling each one with several different values. Here are the functions: 1) rprint - Recursive Printing: Design a recursive function that accepts an integer argument, n, and prints the numbers 1 up through n. 2) rmult - Recursive Multiplication: Design a recursive function that accepts two arguments into the parameters x and y. The function should return the value of x times...

  • Exercise 1 - Create a List to Sum Values Write a python script that sums the...

    Exercise 1 - Create a List to Sum Values Write a python script that sums the values in a list called add_list that contains the following values: (10, 2, -4, 8). Make sure you include a for loop when iterating through the list to sum the values. Take screenshots of the code and output. Exercise 2 – Create a Dictionary Write a python script that prints a dictionary where the key numbers are 1, 2, 3, 4, and 5 and...

  • in python 3 Create a list or tuple with 5 different integers. Prompt the user for...

    in python 3 Create a list or tuple with 5 different integers. Prompt the user for an integer. If the number is in the list (or tuple) print a message stating the number was found. Otherwise, print a message stating the number was not found. Assume the list includes the numbers 0, 2, 4, 6, 8, and 10.

  • 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...

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