22. Rewrite the complete Python script after replacing the while-loop with a for-loop.
astr=input('Input a string? '))
c, s=-1, ""
while True:
c+=1
if c==len(astr): break
s+=astr[k]
print(s)
What will be the output when inputted value of astr is BOWL? [2]
23. Give the output of the Python script given below: [2]
neta, netb='CoMpUtEr', ""
for k in range(8):
if neta[k].isupper():
ch=neta[k].lower()
elif neta[k].islower():
if k%2:
ch=neta[k-1]
else:
ch=neta[k].lower()
netb+=ch
print(netb)
24. Give the output of the Python script given below: [3]
alist=[469, 378, 594, 678, 253]
for number in alist:
x, y=number%100, number//10
print(x+y, end='@')
Answers
Answer:
afraid to blame you mean by formatting the work of art in a g and the fly answer short time to blame you mean by formatting work sheet in the work of art in a g of art we had to you but they'll into B is 52 and we had to be also known as the biggest question and answer you be hair Kashmir is a rest you know we be must have to you to you and what they hastily28eyelets7 and the work of art in a g and the work first trickster and to blame you mean by formatting the same time
Explanation:
In programming languages, a loop may be applied from either the main program of a program or from other functions. Same applies to Python language.
There are many types of loop, while and for loops are the most common types
The for loop version of the given program will be;
astr=input('Input a string? '))
s=-1, ""
for(c=-1, not cc==len(astr,c++):
s+=astr[k]
print(s)