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
Taking an online class doesn't require any special skills.
mr_godi [17]

Answer:

F

Explanation:

It depends on whether the person has interest in it

5 0
3 years ago
Read 2 more answers
What subsection of the Internet requires specialized browser to access and is frequently used by cyber criminals and underground
kotykmax [81]

Answer:

c. Dark Web                                                

Explanation:

Surface web is also called visible web is a part of world wide web that can be easily searchable using search engines as its contents are indexed by the search engines such as Google and its contents are accessible by public using standard web browsers. So a is not a suitable choice.

Deep Web is called invisible web as it is not accessible or searchable to standard search engines like Google. Search engines cannot index the contents of these sites. However such sites do not requires specialized browsers to access. So b is not a suitable choice.

Dark Web: It is a part of Deep Web sites but it requires specialized software and browsers to access. These sites cannot be indexed and cannot be searchable through standard search engines. This is also called dark side of the world wide web darker which is frequently used by criminals, hackers, black markets, hit-men. Illegal activities on a massive level is takes place in the dark web such as access to stolen sensitive information, malware, drug trade and terrorist operations. These sites are temporary and keep changing addresses to lessen the risk of getting caught by govt agencies or security officials. So c is the suitable choice.

Crypto-Net is a kind of neural network which works with encrypted data which can make a prediction based on the data without disclosing the data and prediction to the 3rd party. So d is not a suitable option.

6 0
2 years ago
What was one important academic skill the blogger learned?
denis23 [38]

An academic skill that the blogger learned, was to review the graded tests and quizzes to see which concepts he missed out on so that in the future he would be well prepared for it. Reviewing and comparing the tests and quizzes would give him an idea on which topics he needs to study.

Other than the academic skill, the blogger also learned that a person should never give up and he keeps on learning throughout his entire life, and that all of the improvements that the blogger made did not come all at once.

4 0
3 years ago
A system forensics specialist has three basic tasks related to handling evidence: find evidence, preserve evidence, and ________
dmitriy555 [2]

Answer:

It would be Store

Explanation:

hope this helps if not sorry :(

3 0
2 years ago
The PadRight function has two parameters: S (a string) and N (an int), and returns as its result the string S padded on the righ
oee [108]

Answer:

The following code is written in python programming language:

def PadRight(S,N):   #define user defined function

 if(len(S)<N):    # set if condition

   S=S.ljust(N)   #set the space to right

   return S       # return the result

 

def PadLeft(S,N):    #define user defined function

 if(len(S)<N):    # set if condition

   S=S.rjust(N)   # set the space to left

   return S       # return the result

'''calling the function'''

print(PadLeft("Frog",7))

print(PadRight("Frog",7))

Output:

      Frog

Frog

Explanation:

Here, we define a user defined function "PadRight()" and pass two arguments in its parameter "S", "N".

Then, set the if condition and pass condition "len(S)<N" then, if the condition is true then the code inside the if condition set the space to right then, return the output.

After that, we again define a user defined function "PadLeft()" and pass two arguments in its parameter "S", "N".

Then, set the if condition and pass condition "len(S)<N" then, if the condition is true then the code inside the if condition set the space to right then, return the output.

6 0
3 years ago
Other questions:
  • What procedures are involved in saving a file for the first time?
    10·2 answers
  • Robin ensures that she is always available if anyone in the team needs her. Which quality is shown by robin?
    9·2 answers
  • 6. A distribution consists of three components with frequencies 200, 250 and 300 having means
    14·1 answer
  • Plot element is typically the turning point in the most intense moment of a story
    8·1 answer
  • Which type of computer graphic can be blown up to a much larger size without getting distorted or losing quality?
    5·1 answer
  • Which does plug-and-play refer to?
    14·1 answer
  • Jason is working on a project that requires him to manage a huge amount of data. The spreadsheet he is working on has data relat
    15·1 answer
  • Choose all stages of the information processing cycle.
    12·2 answers
  • How to create create a database in mysql using clv files
    11·1 answer
  • A computer is the __________ of an attack when it is used to conduct an attack against another computer.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!