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]
3 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]3 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
I want to start a debate about something
vovangra [49]

Answer:

I agree for 13-yrs old not having driving licenses because they will become a lot of wrecks and they also can kill themselves or someone and I also agree that they should not be able to get jobs because if someone stills something or a robbery happens then they could get kidnapped or they could get shot

3 0
3 years ago
Read 2 more answers
When an event occurs, the agent logs details regarding the event. what is this event called?
Nimfa-mama [501]

If an event occurs, the agent logs details regarding the event. what is this event called GET.

The information in the agent log file is known to be the beginning of the log file, which is stated to show the agent's launch and handling of the services and configuration settings.

Keep in mind that the agent log also contains a history of the activities performed by the agent during runtime, along with any errors, and that it is utilised to investigate deployment issues.

As a result, if an event happens, the agent logs information about it. What is this GET event, exactly?

The agent monitoring services' startup and configuration settings are displayed at the log file's beginning. The sequence of agent runtime activity and any observed exceptions are also included in the agent log.

Learn more about agent logs:

brainly.com/question/28557574

#SPJ4

8 0
1 year ago
What is the different sheets in excel
enyata [817]

Answer:

By clicking the sheet tabs at the bottom of the Excel window, you can quickly select one or more sheets. To enter or edit data on several worksheets at the same time, you can group worksheets by selecting multiple sheets. You can also format or print a selection of sheets at the same time.

Explanation:

hope this helps

5 0
3 years ago
What is the binary conversion of 179.187.223.21?
Lemur [1.5K]

Explanation:

I hope its the correct answer i'm not sure!

6 0
3 years ago
Read 2 more answers
How do you customize Track Changes in a text document?
lora16 [44]

If its on document u go to text u highlight ur text and then you go upload track changes text on computer or phone or any divice and then you insert the text u wrote to the app and then if u cant find the app look for text changing colors and then copy and past ur work to the app and add the colors to it.

8 0
4 years ago
Other questions:
  • Rearrange the statements in the following order so that the program prompts the user to input: a. The height of the base of a cy
    12·1 answer
  • In Word, tables can be styled much like text can.<br> True<br> False
    6·1 answer
  • Digital information is stored using a series of ones and zeros. Computers are digital machines because they can only read inform
    15·1 answer
  • "Your friend is having a birthday and you want to create a slide-show presentation with pictures of her that you have saved on y
    15·1 answer
  • The conversion of decimal 0.0625 into its binary equivalent. Explain.
    7·1 answer
  • PLEASE HELP ASAP!!
    6·2 answers
  • True or false? Software application packages function as the interface between the operating system and firmware.
    7·1 answer
  • The base position for your fingers to be placed on a keyboard is called<br> 2 point
    15·2 answers
  • Imagery functions as a coding system to help individuals acquire movement patterns. this describes
    6·1 answer
  • Which of the following is not a secondary memory. (a) pen drive (b) Hard disk (c) Ram (d) Magnetic disk
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!