So the programming language for this problem is python. How do I create a function that allows the user to define how many numbers they want to input?This is the problem: 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:5 50 60 140 200 75 100the output is:50 60 75The 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.I want to create a variable that allows the person to input a number that tells the interpreter to only allow input of their certain defined number How do I do that?

Question
Asked Oct 10, 2019
389 views

So the programming language for this problem is python. 

How do I create a function that allows the user to define how many numbers they want to input?

This is the problem: 

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:

5 50 60 140 200 75 100

the output is:

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.

I want to create a variable that allows the person to input a number that tells the interpreter to only allow input of their certain defined number 

How do I do that?

check_circle

Expert Answer

Step 1
  • In this python program, The user is asked to enter an array of integers. 
  • First index of this array represents number of inputs between first and last index.
  • Last index tells the interpreter to print all inputs less than or equal to last index.
Step 2

Full python program

#Enter input in single line separated by space

a = [int(x) for x in input().split()]

length= len(a)

for i in range(length):

if i==0:
con...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: Oscar has invested a huge amount of money into the stock market and doesn't trust just anyone to giv...

A: Given three variables p, m and z where p=Pain Webster, m=Meg A. Cash and z=LaZora.As per the conditi...

question_answer

Q: Programming Question: Write a program in MIPS assembly language that asks the users to enter a value...

A:  Code which is written in MIPS assembly language is shown below-

question_answer

Q: 1. Write a program in python that contains a main function and a custom, void function named show_la...

A: Program AlgorithmIn the main(), generate the two random numbers and call the function show_larger() ...

question_answer

Q: Write two cin statements to get input values into birthMonth and birthYear. Then write a statement t...

A: Explanation:A C++ program should include header file “<iostream>”, begins with “#” sign.This h...

question_answer

Q: How would I network two computers at home?

A: RequirementsTo network two home computers, you will need the following:Broadband internet connection...

question_answer

Q: I need some help arranging these countries in a C++ program : China: 1,433,783,686 India: 1,366,417,...

A: Program AlgorithmDeclare two arrays named country and population of size 14.Using for loop enter the...

question_answer

Q: 3. Which command can you use to look for the file names status.report? Which command can you use to ...

A: The command used to look for files is ‘find’ command. Find command can be used with many criteria to...

question_answer

Q: Create a conditional expression that evaluates to string "negative" if userVal is less than 0, and "...

A: To create a conditional expression, by adding some code statements to the given program code to chec...

question_answer

Q: PLEASE EXPLAIN ALL STEPS (including how k-map formation is formed): simplify the boolean equations: ...

A: Some of the simple rules follows to simplify Boolean expression: