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
expeople1 [14]
2 years ago
5

How many times will line 7 be executed when the following code is run?

Computers and Technology
1 answer:
cluponka [151]2 years ago
8 0

Answer:

4 times

Explanation:

Required.

How many times will line 7 be executed?

Line 2 initialises i to 0

Line 3 subtracts 1 from the length of "rebellion" , the result of the subtraction is then saved in J

So:

j = 9 - 1

j = 8

From line 2 and line 3, we have that:

i = 0 and j = 8

Line 4 is an iteration that is repeated as long as i is less than j

Line 7 will be executed, for the first time as: i < j because 0 < 8

i is incremented to 1 and j is reduced to 7

Line 7 is then executed again, the second time because 1 < 7

i is incremented to 2 and j is reduced to 6

Line 7 is then executed again the third time because 2 < 6

i is incremented to 3 and j is reduced to 5

Line 7 is then executed again the fourth time because 3 < 5

i is incremented to 4 and j is reduced to 4

At this stage, line 7 will no longer be executed because I is no longer less than as 4 = 4.

Hence, number of execution is 4 times

You might be interested in
Vocabulary and Bridge Information
motikmotik
Umm
This is to bunch of questions..
6 0
2 years ago
A loop within another loop is known as a(n) ____ loop.
Natali [406]
Nested






..................................
4 0
2 years ago
Write a program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename
pickupchik [31]

Answer:

Explanation:

iname=input("Enter the file name: ")

inputfile=open(iname,'r')

lines=[]

for line in inputfile:

lines.append(line)

inputfile.close()

print("The file has ",len(lines)," lines")

while True:

linenumber=int(input("Enter the line number or 0 to quit: "))

if linenumber==0:

break

elif linenumber > len(lines):

print("Error: line number must be less than ", len(lines))

else:

print(linenumber, " : ", lines[linenumber - 1])

7 0
3 years ago
What did early computers use to store each bit?
Damm [24]

Answer:

A vacuum tube

4 0
3 years ago
Read 2 more answers
Which type of cause and effect organizer would be best for alisha to understand how crude oil becomes gasoline?
sukhopar [10]
The answer is 100% B. Flow chart.
5 0
3 years ago
Read 2 more answers
Other questions:
  • A factory has a dedicated room just for computers. They are generally kept locked in the room and are never directly used by use
    5·2 answers
  • When people need information, they typically turn to:
    7·1 answer
  • In the u.s.all financial institutions are required to conduct business at a physical location only
    9·1 answer
  • write an application to presell a limited number of cinema tickets. each buyer can buy as many as 4 tickets. No more than 100 ti
    8·1 answer
  • Ruby is creating a presentation. She wants each slide displayed at intervals of five seconds. Which feature in the presentation
    6·2 answers
  • Which steps would you take to determine how much an employee should be paid? Select all that apply.
    9·1 answer
  • True or false? The following deterministic finite-state automaton recognizes the set of all bit strings such that the first bit
    7·1 answer
  • Which symbol is at the beginning and end of a multiline comment block? &amp;&amp;&amp; """ %%% ###
    5·1 answer
  • In the digital age we have less time to absorb and make sense of new information
    12·2 answers
  • If a user wants to change one small section of the formatting of a document and leave the rest the same, which
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!