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
kenny6666 [7]
2 years ago
7

Write a program that asks the user how many numbers will be entered and then has the user enter those numbers. When this is done

, report to the user the position of the first 7 entered and the last 7 entered. By position we mean, for example, that if the first 7 is the 2nd number entered then its position would be 2.

Computers and Technology
1 answer:
KATRIN_1 [288]2 years ago
7 0

Answer:

<em>The program written in Python 3 is as follows;</em>

<em>The program does not make use of comments; however, see explanation section for detailed line by line explanation of the program</em>

num = int(input("Number of Inputs: "))

mylist = []

userinput = int(input("Enter a digit: "))

i = 1

while i < num:

     mylist.append(userinput)

     userinput = int(input("Enter a digit: "))

     i += 1

   

try:

     first7 = mylist.index(7)+1

     print('The first position of 7 is ',first7)

     last7 = num - 1 - mylist[::-1].index(7)

     print('The last position of 7 is ',last7)

except:

     print('7 is not on the list')

Explanation:

This line prompts user for the number of inputs

num = int(input("Number of Inputs: "))

This line declares an empty list

mylist = []

This line inputs the first number into the empty list

userinput = int(input("Enter a digit: "))

The italicized lines represent an iteration that allows user to input the numbers into the empty list.

<em>i = 1</em>

<em>while i < num:</em>

<em>      mylist.append(userinput)</em>

<em>      userinput = int(input("Enter a digit: "))</em>

<em>      i += 1</em>

The try-except is used to check the presence of 7 in the list

try:

This checks the first occurrence of 7

     first7 = mylist.index(7)+1

This prints the first occurrence of 7

     print('The first position of 7 is ',first7)

This checks the last occurrence of 7

     last7 = num - 1 - mylist[::-1].index(7)

This prints the last occurrence of 7

     print('The last position of 7 is ',last7)

The following is executed if there's no occurrence of 7

except:

     print('7 is not on the list')

See Attachments for sample runs

You might be interested in
unlike the barcode-based tracking system, a radio frequency identification system offers a .
Over [174]

Unlike the barcode-based tracking system, a radio frequency identification system offers a <u>no-contact, no-line-of-sight reading, and tracking system</u>.

What is a tracking system?

A tracking system often referred to as <u>a locating system, is used to keep </u><u>track </u><u>of people or objects in motion and provide an accurate, timely sequence of location data for processing</u>. Human tracking should be understood; more information is provided below.

<u>Any stolen car can be kept </u><u>track </u><u>of across the nation</u> with the use of a tracking system, ensuring that it is returned as soon as possible. A tracking system is a crucial tool for making sure your personnel is safe.

To learn more about tracking system, use the link given
brainly.com/question/15237193
#SPJ4

8 0
1 year ago
Which statement reflects an opinion about technology? Select all that apply. Select one or more: a. It is easy to imagine that a
True [87]

Answer:

All options apply to the question because each one reflects one side of technology in relation to the artist's case (that could be a software engineer or a even a hardware designer).

Explanation:

Letter a applies to the question in terms of computer program's behavior with no people's assistance, which is something not real for the present time, although it is easy to imagine that it is going to be a reality in a near future for all the improvements engineers and developers have made. Letter b also applies because computers and softwares have become one of the most important tools for artists around the world, whether for researching and/or for sharing and/or selling their productions, however it is a radical idea to think an artist is not necessary anymore, that is similiar to say human beings are not necessary only because machines have improved. Letter c also applies to the question for all improvements made in art and art forms after all improvements made in technology and tools for technologies development. And, letter d also applies because computers may be used for studying and/or working, which is the perfect tool for a workplace, and this is why it has become essential in many organizations, companies, subsidiaries, agencies, schools, and more.

3 0
3 years ago
You are part of the team to implement new software at XYZ Inc. The employees at XYZ Inc. trust the results of the old software p
sasho [114]

Answer:

Option (D) i.e., Parallel start up is correct option to the following question.

Explanation:

Parallel startup is also an application or software or a way of using the application of the other Operating System in others just like that the following XYZ inc. has trust on older platform but their system give them cautions for update then they use parallel set up by which they also use old software, as well as they, use the Mac's software in Windows. This strategy provides both the option of usage.

8 0
3 years ago
152<br>what is the role of Computer as<br>transforming agent in the<br>Information society.​
hichkok12 [17]
I have a question what grade are you in
8 0
2 years ago
the part of the computer that provides access to the internet is the A.modem B. keyboard C. monitor or D.system unit
marta [7]
A. the modem provides the wifi or internet to the computer
6 0
3 years ago
Read 2 more answers
Other questions:
  • Can someone please help me write a code for this
    7·1 answer
  • Your motherboard supports dual channeling and you currently have two slots used in channel a on the board; each module holds 1 g
    15·1 answer
  • What is the amount of a good or service that business have available to sell?
    13·1 answer
  • Word 2013 in order to share a document online you must first
    10·1 answer
  • On a piano, a key has a frequency, say f0. Each higher key (black or white) has a frequency of f0 * r^n, where n is the distance
    10·1 answer
  • How Oracle 12c advances the security discussion?
    12·1 answer
  • Why can’t I “change the country” on settings??<br> (In this app)
    13·1 answer
  • What are candid shots? what are posed shots?
    13·1 answer
  • Charlie makes pizza at a restaurant. The customers always compliment how great the pizza tastes. But Charlie takes a long time t
    7·2 answers
  • Are there any Potential Dangers in Artificial Intelligence?
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!