Question: Can i please have some help with these two trace table python questions? QUESTION 1 One effective method often used by programmers to comprehend the

Can i please have some help with these two trace table python questions?

QUESTION 1

One effective method often used by programmers to comprehend the effect of code is "tracing". Tracing is hand-executing the code in the same sequence and manner that the computer would execute the program. Often, the changes made to variables in the code are recorded in a "trace table". Each row in the trace table records the values of the variables after a corresponding statement in the left hand column of the trace table has been hand-executed.

For example, for the code

holden = 2 ford = 13 mitsubishi = 5

a completed trace table would be:

holden

ford

mitsubishi

holden = 2

2

-

-

ford = 13

2

13

-

mitsubishi = 5

2

13

5

Your task is to trace execution of the following Python code and keep track of variables index, where and answer:

Can i please have some help with these two trace

index

where

answer

nums = [3, 1, 2, 10]

-

-

-

where = 0

-

0

-

for index in range(1, len(nums)):

# (TRACE TABLE STARTS HERE, FILL IN THE BLANK BOXES BELOW)

if nums[index] nums[where]:

where = index

#

if nums[index] nums[where]:

where = index

#

if nums[index] nums[where]:

where = index

# end loop

answer = nums[where]

QUESTION 2

One effective method often used by programmers to comprehend the effect of code is "tracing". Tracing is hand-executing the code in the same sequence and manner that the computer would execute the program. Often, the changes made to variables in the code are recorded in a "trace table". Each row in the trace table records the values of the variables after a corresponding statement in the left hand column of the trace table has been hand-executed.

For example, for the code

holden = 2 ford = 13 mitsubishi = 5

a completed trace table would be:

holden

ford

mitsubishi

holden = 2

2

-

-

ford = 13

2

13

-

mitsubishi = 5

2

13

5

Your task is to trace execution of the following Python code and keep track of variables last and which:


last

which

numbers1 = [5, 50, 500]

-

-

numbers2 = [10, 20, 500]

-

-

last = -1

-1

-

which = 0

-1

0

while which len(numbers1):

# (TRACE TABLE STARTS HERE, FILL IN THE BLANK BOXES BELOW)

if numbers1[which] >= numbers2[which]:

last = which

which = which + 1

#

if numbers1[which] >= numbers2[which]:

last = which

which = which + 1

#

if numbers1[which] >= numbers2[which]:

last = which

which = which + 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!