Find the output of the following script in python note all


Part 1 : Rewrite the following for loop Python statements using while loop.

phrase = "Iowa State University"

index = 0

for ch in phrase:

if (ch == "t") or (ch == "T"):
print ch + " at index " + str(index)
index += 1

Part 2 : Find the output of the following script in Python. Note: All statements are valid.

a.

myList = [1, 2, 3, 4, 5]

for i in range(1,5,2):
print myList[i]

b.

myList = ["aaa", "bbb", "ccc", "ddd", "eee", "fff"]

i = -1
while i > len(myList)*-1:
print myList[i]
i -= 1

c.

myList1 = [1, 2, 3]
myList2 = [1,2]
for r in myList1:
for c in myList2:
print r+c , "\t" ,
print

Solution Preview :

Prepared by a verified Expert
Python Programming: Find the output of the following script in python note all
Reference No:- TGS01412403

Now Priced at $30 (50% Discount)

Recommended (91%)

Rated (4.3/5)