The document contains 11 coding questions with sample code and instructions to find the output. Some key points:
- Question 1 fixes syntax errors in a loop that prints maiden or not maiden.
- Question 2 outputs a new string from str1 by adding/replacing characters based on conditions.
- Question 3 prints names from a list, breaking out of the loop if the first letter is 'T'.
- Question 4 prints numbers from 1 to values in a nested loop.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
106 views1 page
Assignment Cs 4011
The document contains 11 coding questions with sample code and instructions to find the output. Some key points:
- Question 1 fixes syntax errors in a loop that prints maiden or not maiden.
- Question 2 outputs a new string from str1 by adding/replacing characters based on conditions.
- Question 3 prints names from a list, breaking out of the loop if the first letter is 'T'.
- Question 4 prints numbers from 1 to values in a nested loop.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1
Assignment -1 Topic : Revision tour -1 7.
What is the output of the following
Class XII Computer Science Def changeval(m,n): 1. Rewrite the code after removing syntax for I in range(n): error underline each correction done in the If m[i]%5==0: code m[i]//=5 runs=(10,5,0,2,4,3) If m[i]%3==0: for I in runs: M[i]//=3 print(maiden over) L[25,8,75,12] else Changeval(L,4) print( not maiden) For I in L : 2. what is output ? Print(I,end=’#’) Str1=”exam2018” 8. find the output ? Str2=’ ‘ Name=”PythoN3@1” I=0 R=’’ While i<len(str1): for x in range(len(name)): If str1[i]>=’A’ and str1[i]<=’M’: if name[x].isupper(): Str2=str2+str1[i+1] R=R+name[x].lower() elif str1[i]>=’0’ and str1[i]<=’9’: elif name[x].islower(): str2=str2+str1[i-1]) R=R+name[x].upper() else: elif name[x].isdigit(): str2=str2+’*’ R=R+name[x-1] i=i+1 else: print(str2) R=R+’#’ 3. what is output Print(R) for name in [‘jayes’,’Ramya’,’Taruna’,’Suraj’]: 9. Find the output ? Print(name) def change(num1,num2=50): If name[0]==’T’: num1=num1+num2 Break num2=num1-num2 else: print(num1,’#’,num2) print(‘finished’) return (num1) print(‘got it ‘) n1=150 n2=100 4. what is output ? n1=change(n1,n2) Values=[10,20,30,40] print(n1,’#’,n2) for val in values: n2=change(n2) for I in range(1,val%9): print(n1,’#’,n2) print(I,”*”,end=’’) 10. Observe the python code and find the print() output? 5. What is outut ? a=”Giodo Van Rossum” L1=[100,900,300,400,500] a=a.split() Start=1 b=a[0][0]+”.”+a[1][0]+a[2] Sum=0 print(b) For c in range(start,4): 11. What is output ? Sum=sum+L1[c] s=“welcome2cs” Print(c,”:”,sum) n=len(s) Sum=sum+L1[0]*10 m=”” Print(sum) for I in range(0,n): 6. what is output ? if s[i]>=’a’ and s[i]<=’m’: Data=[‘P’,20.’R’,10,’S’,30] m=m+s[i].upper() Times=0 elif (s[i]>=’n’ and s[i]<=’z’): alpha=’’ m=m+s[i-1] add=0 elif (s[i].isupper()): for c in range(1,6,2): m=m+s[i].lower() times=times+c else: alpha=alpha+data[c-1]+’$’ m=m+’&’ add=add+data[c] print(m) print(times,add,alpha)