IN PYTHON Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, get the last value from the input, and output all integers less than or equal to that value.

Ex: If the input is:

Enter the number of integers in your list: 5
Enter the 5 integers:
50
60
140
200
75
Enter the threshold value: 100
the output is:

The integers that are less than or equal to 100 are:
50
60
75

The 5 indicates that there are five integers in the list, namely 50, 60, 140, 200, and 75. The 100 indicates that the program should output all integers less than or equal to 100, so the program outputs 50, 60, and 75. Such functionality is common on sites like Amazon, where a user can filter results. Your code must define and call the following two functions: def get_user_values() def output_ints_less_than_or_equal_to_threshold(user_values, upper_threshold) Utilizing functions will help to make your main very clean and intuitive.

Answers

Answer 1
Answer:

Answer:

def output_ints_less_than_or_equal_to_threshold(user_values, upper_threshold):

 for value in user_values:

     if value < upper_threshold:

         print(value)  

def get_user_values():

 n = int(input())

 lst = []

 for i in range(n):

     lst.append(int(input()))

 return lst  

if __name__ == '__main__':

 userValues = get_user_values()

 upperThreshold = int(input())

 output_ints_less_than_or_equal_to_threshold(userValues, upperThreshold)

Explanation:


Related Questions

Given the following code segment, what is output after "result = "? int x = 1, y = 2, z = 3; cout << "result = " << (x < y ? y : x) << endl;a. 1 b. 2c. 3d. 4
Write a program that reads in 10 numbers from the user and stores them in a 1D array of size 10. Then, write BubbleSort to sort that array – continuously pushing the largest elements to the right side
Hello,Can you please help me with the following questions:3. You enjoy technical matters, have a background in computer science and enjoy coding and playing video games in your free time. Which video game industry job would best match your profile?a. Game testerb. Producerc. Programmerd. Video game artist6. Which of the following is an essential skill for game testers?a. Thorough understanding of Java and C++b. Technical drawingc. Technical writingd. Project management9. Which of the following skills is the most important when applying for a game artist job?a. Degree in artsb. Strong art portfolioc. Previous game testing experienced, knowledge of scripting and codeing10. The Stencyl program is recommended for ______.a. creating 2D gamesb. creating 3D gamesc. Starting to learn to programd. creating gaming art11. You are passionate about video games, have spent part of your life in different countries and are fluent in their languages. You are considering looking for a job in video games. Which of the following jobs could you be qualified for, considering your skills and experience?a. Game programming with a focus on languagesb. Translationc. Game localizationd. Cultural gaming12. Because it is one of the main programming languages used in some of the most popular game engines in the industry, which programming language does the author of the textbook recommend learning first?a. Javab. C Sharpc. C++d. SQL13. Which of the following statements is NOT true about internships?a. internships offer great opportunity to create and build connections within the industry.b. Internships lead to a job offer upon successful completionc. Internships offer an opportunity to get first-hand experience of the industryd. Internships can be paid or unpaid15. What is the best approach to take if you have not heard back from a company after applying for a job?a. Wait, sometimes it takes time to process application and impatience can give a bad impressionb. Visit the company site personally to inquire about the status of your applicationc. Try to find out on which side the process may be stalling and take appropriate steps to get the process moving forward, when possibled. Reapply18. You are applying for a game programmer job at a reputable gaming company. Your application may stand the best chance of being noticed if you include which of the following in your application?a. List of all degrees and courses you have taken to acquire and hone your programming skillsb. Portfolio including samples of codes you have createdc. Portfolio including playable video game demo.d. Portfolio of your artwork.19. Which of the following is the most important item to include in your CV?a. All gaming projects you have worked on, paid or unpaid.b. Extracurricular activities related to gaming.c. Major accomplishmentsd. Short samples of code or technical writing samples.20. Which of the following job hunting practices is the least effective?a. Posting CV on job boards.b. Searching for jobs on job posting sitesc. Doing an internshipd. Applying for a specific job posting via company website
Write a loop that continually asks the user what pets the user has, until the user enters "rock", in which case the loop ends. It should acknowledge the user in the following format. For the first pet, it should say "You have a dog with a total of 1 pet(s)" if they enter dog, and so on. Sample Run: User enters: lemur parrot cat rock Outputs: You have a lemur with a total of 1 pet(s) You have a parrot with a total of 2 pet(s) You have a cat with a total of 3 pet(s)
Who could vote in the first democracy?A. EveryoneB. CitizensC. AdultsD. Women

What is the tool that is used to automatically search New information on the internet and organize if for future searches?

Answers

the answer would be a "web crawler"

What is computer?iwhat is computer ​

Answers

Answer:

an electronic device for storing and processing data, typically in binary form, according to instructions given to it in a variable program

Explanation:

Answer:

a divice to play games on, learn on, and other helpful things

Explanation:

Egovernment involves the use of strategies and technologies to transform government by improving the delivery of services and enhancing the quality of interaction between the citizen-consumer within all branches of government. Group of answer choices

Answers

What are you asking for

Write a program that removes all non-alpha characters from the given input. Ex: If the input is: -Hello, 1 world$! the output is: HelloworldAlso, this needs to be answered by 11:59 tonight.

Answers

Answer:

Explanation:

The following code is written in Python. It is a function that takes in a string as a parameter, loops through the string and checks if each character is an alpha char. If it is, then it adds it to an output variable and when it is done looping it prints the output variable. A test case has been provided and the output can be seen in the attached image below.

def checkLetters(str):

   output = ''

   for char in str:

       if char.isalpha() == True:

           output += char

   return output

. How are returnspredicted in modern microprocessors?

Answers

Answer:

Return are predicted in the modern microprocessor as, branch predictor is the modern method for the processor for the prediction. The basic function of the branch predictor is improving in the pipeline instruction. It is basically the important part for implement the execution and the pipe lining. And the return predicted uses the call by reference technique for the data in instruction.

what are "open source" programming language? Give examples of open source languages. Discuss the pros and cons of open source language.

Answers

Answer:

  The open source is the programming language that basically falls inside the parameters of the protocol of open-source convention. This fundamentally implies the language are not proprietary, with the specific arrangements (contingent upon the open source permit), can be adjusted and based upon in a way that is available to general society.

The python and ruby are the main examples of the open source programming language.

The disadvantage of the open source is that it is not much compatible as compared to all other software. It is not user friendly and easy for using the software.

The advantage of the open source programming is that it is available at low cost and it has high availability.

Other Questions
Quicksort reaches the worst-case time complexity when:Partition is not implemented in placePicking the largest one of input or partitioned data as pivot valueMedian of input or partitioned data is expensive to calculateData is sorted already and always pick the median as pivotChoose the incorrect statement:When the median is always picked as pivot in input/partitioned data, then quicksort achieves the best-case time complexity.Mergesort has O(N(log(N)) time complexity for its worst case, average case and best caseInsertionsort reaches its best-case time complexity O(N log(N)) when the input data is pre-sortedQuicksort is practically fast and frequently used sorting algorithm.Choose the incorrect statement:In the lower bound analysis by using decision tree, each branch uses one comparison to narrow down possible casesIn the lower bound analysis by using decision tree, he number of required comparisons can be represented by height of decision treeA decision tree to sort N elements must have N^2 leavesO(N log(N)) lower bound means that comparison-based algorithm cannot achieve a time complexity better than O(N log(N))Choose the incorrect statement regarding time complexity of union-find operation:Inverse Ackermann function does not depend on N and is a constant factor.When we use arbitrary union and simple find for union-find operation, the worst-case time complexity is O(MN) for a sequence of M operations and N elementsUnion-by-size and Union-by-rank both improve the time complexity to O(M log(N)) for a sequence of M operations and N elementsTo finish the entire equivalence class computation algorithm, we need to go over each pair of elements, so if we use union-by-rank with path compression for find operation, then the overall time complexity is O(N^2 log*N), where log*N denotes the inverse Ackermann function.Choose the incorrect statement regarding Dijstraâs algorithmDijstraâs algorithm is a greedy algorithmDijstraâs algorithm requires to dynamically update distance/costs/weights of paths.To begin with, Dijstraâs algorithm initializes all distance as INFDijstraâs algorithm can be implemented by heaps, leading to O(|E|+|V| log(|V|)) time complexity, where, particularly, log(|V|) is due to "insert" operation in heaps.