147k views
4 votes
) Find and write the o/p :

X=[“F”,66,”QE”,15,”S”,34]
Y=0
Z=” ”
A=0
for c in range(1,6,2)
Y+=c
Z=Z+X[c-1]+'$’
A+=X[c]
Print(x,y,z)

User Mobs
by
5.6k points

1 Answer

5 votes

Answer:

The output of this question is

['F', 66, 'QE', 15, 'S', 34] 9 F$QE$S$

Step-by-step explanation:

In this question the user want to print the value of X,Y and Z

Let calculate the value of X first.

As the value of X is not altered in the program to its value will be the same that is:

['F', 66, 'QE', 15, 'S', 34]

Now we will calculate the value of Y

It is written as

Y+=c

which can be written as Y=Y+c

The loop here start form 1, the it go to 3 then 5 as explained below

Range(1,6,2) is written

The first value is the start value

The second value is stop value

While the third value is how much to increment.

So first its value will be 1 then increment it by 2. It will become 3

then increment it by 2 again it will become 5. in the next step it will become 7 which is out of range

so

Y=Y+c => Y=0+1 (first loop)

Y=1+3 (second loop)

Y=4+5 (third loop)

Some y will be 9

Now let focus on the value of Z

Z= " " +X[1-1]+'$' (first loop) value of c=1

so it will become

Z=F$

Now in 2nd Loop

Z=" " + X[3-1]+'S' (2nd loop) value of c=3

it will become

Z=QE $

Now in 3rd Loop

Z=" " + X[5-1]+'S'

it will become

Z=" " S + $

so the overall answer of print will become

['F', 66, 'QE', 15, 'S', 34] 9 F$QE$S$

User Arthu Santiago
by
6.2k points