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
Romashka [77]
3 years ago
6

Create an empty text document name "input.txt" and copy the example contents from below: 5 105 15 20 35 47 The first value in th

e file tells you how many ints (the type must be int!) are in the file. The rest of the values are the ints you want to store. Create a program that reads in the first value, always an int, that tells you how many values are in the file. Then, create an array to store all of those values. After you've read in the values display them to the screen in the following format: Contents of input.txt: [105, 15, 20, 35, 47] Input a value to search for: The search prompt obtains a value from the user and confirms whether or not it is in the array. Example: Contents of input.txt: [105, 15, 20, 35, 47] Input a value to search for: 5 5 is not in the array. Do you wish to quit (y/n): n Input a value to search for: 105 105 is in the array. Do you wish to quit (y/n): y
Computers and Technology
1 answer:
agasfer [191]3 years ago
7 0

Answer:

  1. with open("input.txt") as file:
  2.    data = file.read()
  3.    inputList = data.split(" ")
  4.    count = int(inputList[0])
  5.    numArr = []
  6.    for i in range(1, count+1):
  7.        numArr.append(int(inputList[i]))
  8.    
  9.    print(numArr)
  10. search = int(input("Input a value to search for: "))
  11. if search in numArr:
  12.    print("Value found in array")
  13. else:
  14.    print(str(search)+ " is not in the array")
  15. choice = input("Do you wish to quit (y/n):")
  16. while(choice != "y"):
  17.    search = int(input("Input a value to search for: "))    
  18.    if search in numArr:
  19.        print("Value found in array")
  20.    else:
  21.        print(str(search)+ " is not in the array")
  22.    
  23.    choice = input("Do you wish to quit (y/n):")  

Explanation:

Firstly, we open a file stream to read the text file and use split method to break the input into a list of individual numbers (Line 1 - 3). We set the first item of the inputList to count variable and create a numArr list (Line 4-5).

Use a for loop to populate the number from inputList to numArr (Line 6-7) and display the number from the list (Line 9).

Next, prompt user to search for a number from list (Line 11).

If the input is matched with one of the item in numArr, display found message or display a not found message if the input is not available in the numArr (Line 13 -16). Prompt the user again to check if the user wish to quit the search (Line 18). If not, repeat the same process to input a search value and check the value is found in the numArr and display appropriate message (Line 21 - 28).

You might be interested in
Please help!!!!!!! 50 POINTS!!!!
mrs_skeptik [129]

Answer:

A,D,C,B are the correct answers

Explanation:

Hope this helps:)

3 0
3 years ago
When cleaning a computer, you need only worry about what you can see.
icang [17]

Answer:

No

Explanation:

Somethimg yu cant see are important

5 0
3 years ago
The item in this illustration that is highlighted is the _____. quick access tool bar view buttons status bar zoom control
tiny-mole [99]

Answer: scrollbar

Explanation:

7 0
3 years ago
Read 2 more answers
What program is considered the industry standard for digital graphics and image editing?
denpristay [2]
I believe photoshop, or illustrator
7 0
3 years ago
Read 2 more answers
content from other sources can be embedded into it linked to a photoshop document from another source
Ann [662]

Answer:

PLEASE MARK MY ANSWER BRAINLIEST

Explanation:

Create embedded Smart Objects

(Photoshop) Choose File > Place Embedded to import files as Smart Objects into an open Photoshop document.

Choose File > Open As Smart Object, select a file, and click Open.

(Photoshop CS6) Choose File> Place to import files as Smart Objects into an open Photoshop document.

3 0
3 years ago
Other questions:
  • Fill in the missing statements or expressions in the following code that checks to ensure that a user enters an integer value at
    11·1 answer
  • Invention I chose was radio.
    9·1 answer
  • Hello, please help write code in C++. Primary U.S. interstate highways are numbered 1-99. Odd numbers (like the 5 or 95) go nort
    12·1 answer
  • When writing about environment concerns, which topic would demonstrate civic-mindedness on a global scale?
    11·2 answers
  • #include
    11·1 answer
  • Fear and superstition were swept away as scientists began to understand natural phenomena, leading to a shift in content for gra
    5·1 answer
  • Qbasic program to check whether an entered number is positive or negative or neutral​
    15·1 answer
  • _____is used to organize and modify the properties of the current selection.
    6·1 answer
  • An international pharmaceutical company is fully compliant with local and international regulations. However, they suffered a ma
    14·1 answer
  • Brent recently received funding for his fast-food chain in Michigan. As a result, he hires Angela to set up a top-level domain s
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!