1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
nlexa [21]
3 years ago
7

In Python, In a program write a function that accepts two arguments: a list, an a number n. Assume that the list contains number

s. The function should display all of the numbers in the list that are greater than the number n. Here is what I have so far.
#call the main function
def main:
#declares local variables
number = 5
number_list = [1,2,3,4,5,6,7,8,9,10]
#displays the number
print('Number', number)
#displays the list of numbers
print('List of numbers:/n', number_list, sep='')
#Display the list of numbers that are larger
#than the number
print('List of numbers that are larger than',\
number, ':', sep='')
#Call the larger_than_n_list function,
#passing a number and number list as arguments.
display_larger)than_n_list(number, number_list)
# The display_largger_than_n_list function acceps two arguments:
#a list, and a number. The function displays all of the numbers
#in the list that are greater than that number.
def display_larger_than_n_list(n, n_list):
#Declare an empty list
larger_than_n_list = []
#Loop through the values in the list.
for valie in n_list:
#Determins if a value is greatter than n.
dont know what goes here
#if so, append the value to the list
larger_than_n_list.append(value)
#Display the list.
print("larger_than_n_list")
#Call the main function
main()

Computers and Technology
1 answer:
Anton [14]3 years ago
8 0

Answer:

#call the main function

def main():

   #declares local variables

   number = 5

   number_list = [1,2,3,4,5,6,7,8,9,10]

   #displays the number

   print('Number', number)

   #displays the list of numbers

   print('List of numbers:\n', number_list, sep='')

   #Display the list of numbers that are larger

   #than the number

   print('List of numbers that are larger than',number, ':', sep='')

   #Call the larger_than_n_list function,

   #passing a number and number list as arguments.

   display_larger_than_n_list(number, number_list)

   # The display_largger_than_n_list function acceps two arguments:

   #a list, and a number. The function displays all of the numbers

   #in the list that are greater than that number.

def display_larger_than_n_list(n, n_list):

   #Declare an empty list

   larger_than_n_list = []

   #Loop through the values in the list.

   for value in n_list:

       #Determine if a value is greatter than n.

       # dont know what goes here

       #if so, append the value to the list

       if (value > n):

           larger_than_n_list.append(value)

   #Display the list.

   print(larger_than_n_list)

#Call the main function

main()

Explanation:

The above is the corrected code and it works properly. Some of the errors noted and corrected include:

  • omission of bracket from of main. It should be main()
  • displaying larger_than_n_list as a string instead of a list reference. It should be print(larger_than_n_list)
  • missing if-statement to compare each element in the list with the value in the argument passed.
  • missing call to the display_larger_than_n_list function

A sample image output of the code execution is attached.

You might be interested in
Styles are modified by using the Office clipboard in the Home tab. true or false
cluponka [151]
Your answer is false
7 0
3 years ago
Read 2 more answers
Define the missing method. licenseNum is created as: (100000 * customID) licenseYear, where customID is a method parameter. Samp
g100num [7]

Answer:

I am writing the program in JAVA and C++

JAVA:

public int createLicenseNum(int customID){  //class that takes the customID as parameter and creates and returns the licenseNum

       licenseNum = (100000 * customID) + licenseYear;  //licenseNum creation formula

       return(licenseNum);     }

In C++ :

void DogLicense::CreateLicenseNum(int customID){ //class that takes the customID as parameter and creates the licenseNum

licenseNum = (100000 * customID) + licenseYear; } //licenseNum creation formula

Explanation:

createLicenseNum method takes customID as its parameter. The formula inside the function is:

licenseNum = (100000 * customID) + licenseYear;

This multiplies 100000 to the customID and adds the result to the licenseYear and assigns the result of this whole expression to licenseNum.

For example if the SetYear(2014) means the value of licenseYear is set to 2014 and CreateLicenseNum(777) this statement calls createLicenseNum method by passing 777 value as customID to this function. So this means licenseYear = 2014 and customID  = 777

When the CreateLicenseNum function is invoked it computes and returns the value of licenseNum as:

licenseNum = (100000 * customID) + licenseYear;

                     = (100000 * 777) + 2014

                     = 77700000 + 2014

licenseNum = 77702014                                                                                                        

So the output is:

Dog license: 77702014          

To call this function in JAVA:

public class CallDogLicense {

public static void main(String[] args) {//start of main() function

    DogLicense dog1 = new DogLicense();//create instance of Dog class

dog1.setYear(2014); // calls setYear passing 2014

dog1.createLicenseNum(777);// calls createLicenseNum passing 777 as customID value

System.out.println("Dog license: " + dog1.getLicenseNum()); //calls getLicenseNum to get the computed licenceNum value

return; } }

Both the programs along with the output are attached as a screenshot.

3 0
3 years ago
Read 2 more answers
IP ______ occurs when an intruder computer fools a network into believing its IP address is associated with a trusted source.
Veseljchak [2.6K]

Answer:

Spoofing

Explanation:

Spoofing that occurs when an intruder computer fools network into believing its IP address is associated with trusted source

5 0
2 years ago
5. ADD A STATEMENT OR STATEMENTS to the program on the following page (including constant and/or variable declarations if you wa
kvasek [131]

Answer:

C code is explained below

Explanation:

#include <stdio.h>

int main() { /* main */

/*

      **********************************************************

      * Declaration Section

      **********************************************************

      *

      * Named Constants

      */

  const int bits_per_byte = 8;

  const int attention_span_in_seconds = 3;

  /*

  * You can insert stuff after this comment.

*/

/*

* Local variables

*/

  int modem_send_speed_in_bits_per_second = 56000;

  int script_file_length_in_bytes = 28000;

  int seconds_to_send_script_file;

  /*

  * You can insert stuff after this comment.

*/

/*

      **********************************************************

      * Execution Section

      **********************************************************

      *

      * You can insert stuff after this comment.

*/

  seconds_to_send_script_file =

      (script_file_length_in_bytes * bits_per_byte) /

      modem_send_speed_in_bits_per_second;

  if (attention_span_in_seconds < seconds_to_send_script_file)

      printf("1\n");

  else printf("0\n");

} /* main */

4 0
3 years ago
Describe two measures you can use to evaluate whether an attachment in a message is reliable to open.
meriva
<span>If a attachment is not reliable to open, terrible effects can happen, peradventure it may have a virus or even malware that can destroy a computers software. 

To avoid this and stay on the safe side, try the following:-

- Open it in protected view 
- Do not save the attachment on your computer 
- Look at the author and read the message carefully to make sure it is not biased. 
- Open it on a flash-drive </span>
8 0
3 years ago
Read 2 more answers
Other questions:
  • Which key removes all data from an active cell with one click
    7·2 answers
  • Dillard’s wants to learn about its consumers' attitudes toward online purchases. There are numerous studies that are available a
    9·1 answer
  • You are adding a new 500 GB hard drive to your computer. The hard drive must be formatted with a file system to organize files i
    8·1 answer
  • The Telecommunications Act of 1996 was a mixed bag for cable customers. Although cable companies argued that it would bring more
    8·1 answer
  • You are given an integer N, followed by N lines of input (1 &lt;= N &lt;= 100). Each line of input contains one or several words
    8·1 answer
  • True or false: The objective of an Enterprise Resource Planning (ERP) system is to create a customized software program that int
    10·1 answer
  • Using a tag, set the color to orange for all tags
    13·2 answers
  • Find examples of conic sections in art and architecture. Visit Web sites to find pictures of artwork or buildings that illustrat
    14·1 answer
  • If I want to make it look like slide number one is turning a page to slide number two, what
    11·1 answer
  • The technique that allows you to have multiple logical lans operating on the same physical equipment is known as a.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!