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
What keyword do we use when instantiating an object _________________
fgiga [73]

Answer:

The correct answer for the given question is option(c) i.e new

Explanation:

Instantiating an object means creating a object or creating a instance of a class .

The new keyword allocates  a memory for the object .

To create instance we follow following syntax

classname objectname =new classname();

for example

abc ob=new abc();

here abc is a class and ob is an object for that class with the help of new keyword it allocate the memory  for the object  ob.

create, =,object ,is are not any keyword to instantiating an object.

so the correct answer is " new "

8 0
3 years ago
​printers, monitors,​ tablets, cpus, and laptops are examples of​ ____________.
AlladinOne [14]
​printers, monitors,​ tablets, cpus, and laptops are examples of​ ____________.

c. hardware
5 0
3 years ago
Based on the current economic situation do you expect the employment demand for graduating engineers to increase or decrease? Ex
Delicious77 [7]

Answer: the employment demand would increase.

Explanation:

Several factors affect the employment demand especially in a field as peculiar as engineering, the cumulative build up of unemployed graduates and the skill set required to fit into the present working structure is also of Paramount importance. The evaluation method for recruitment seeks to function based on this rationale by selecting a few amongst many.

8 0
3 years ago
which of the following commands can be used to display any email messages awaiting delivery alongside the reason that they were
Rasek [7]

The command that can be used to display any email messages awaiting delivery alongside the reason that they were not delivered is known as Mailq.

<h3>What is Email?</h3>

Email stands for Electronic mail. It may be defined as a type of method that significantly involves the exchange of computer-stored messages from one user to one or more recipients via the internet.

The command "Mailq" stands for mail queue. It is the command in Linux that prints the queued mail gain in form of sending it to the user. This command prints a list of messages that are in the mail queue. It is the same as the Sendmail-bp command.

Therefore, "mailq" is the command that can be used to display any email messages awaiting delivery alongside the reason that they were not delivered.

To learn more about Email, refer to the link:brainly.com/question/24688558

#SPJ1

6 0
1 year ago
Which statement describes what the Conditional Formatting option in Excel 2016 allows users to do?
jeyben [28]

Answer:

It automatically applies formatting based on specific rules or conditions being met. It automatically applies highlighting to selected cell ranges based on specific rules or conditions being met.

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • This provides an easy method for workers to use their computers.
    11·2 answers
  • Lydia used software and numerical data to create bar graphs. What software did she use?
    8·2 answers
  • The arithmetic logic unit (alu) controls all of the functions performed by the computer's other components and processes all the
    7·1 answer
  • In step 2 of the mail merge process you must be prepared to
    6·2 answers
  • 1. What are copyright laws? (6 points)
    15·1 answer
  • A ________ is a powerful analytical tool to size up Apple Inc.'s competitive assets in order to determine whether or not those a
    9·1 answer
  • Would you consider upgrading Maxine’s wardrobe a need or a want?
    11·1 answer
  • Netiquette is the
    13·1 answer
  • 2
    5·1 answer
  • 8. Give regular expressions with alphabet {a, b} for
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!