Python Discussed Question
Python Discussed Question
COMPUTER SCIENCE
UNIT-1 PYTHON REVISION TOUR
Discussed Question
print(a[1::2])
python
4. s1=’hello’
a)\n b)\t c) ‘ d) ;
6. print(5+3**2/2)
a)9.5 b)32 c)8.0 d)82.0
a)(1,2,3) b) (‘one’,’two’,’three’)
c) (10,) d) (‘one’)
Module in python?
a)randfloat() b)randint()
c) random() d) randrange()
Operation
a) ‘Welcome’+’10’ b) ‘Welcome’*10
c)’Welcome’*10.0 d) ‘10’+”Welcome”
10. T=(10,20,[30,40,50],60,70)
T[2][1]=100
Print(T)
(10,20,[30,100,50],60,70)
11. L=[10,20,30,40,50]
L=L+5
print(L)
TypeError: can only concatenate list (not "int") to list
12. D{'Tanish':90,'kevin':96,'Gangesh':92,'srini':95}
True#False
(10,20,30,40)
a) T=T+40 b) T=T+(40)
b) T=t+(40,) d) cant insert because tuple is
immutable
print(s.capitalize(),s.title(),end='!')
15. l=[]
for i in range(4):
l.append(2*i+1)
print(l[::-1])
t=('karthi','Shanth','Roshan','Mano')
for i in range(1,5):
D[1]=t[i-1]
print(D)
17. l1,l2=[10,15,20,25],[]
for i in range(len(l1)):
l2.insert(i,l1.pop())
print(l1,l2,sep='&')
for N in range(2,5,2):
print(random.randrange(1,n),end='#')
a) 1#3#5# b)2#3#
C)1#4# d)1#3#
19. t=''
s='PYTHON 3.9'
for i in s:
if i.isdigit():
t=t+i
print(s,t,sep='*')
20. l=[2,6,9,10]
for i in range(len(l)):
if l[i]%2==0:
l[i]=l[i]*2
elif l[i]%3==0:
l[i]=l[i]*3
else:
l[i]=l[i]*5
for i in l:
print(i,end='#')
22. d={1:'ome',2:'tow',3:'three'}
l=[]
if v[0]==7:
l.append(k)
print(l)
Or even
Answer:
num=int(input())
if num%2==0:
else:
a=input()
print(a[::-1])
25. v=25
print(v,end='*')
v=50
print(v,end='!')
v*=2
print(v,end='!')
print(v)
26. s='UVW';l=[10,20,30];d={}
n=len(s)
d[l[i]]=s[i]
print(k,v,sep='4',end=',')
a=int(input(‘enter a:’))
b=int(input('enter b'))
c==int(input('enter c'))
root1=(-b+(b**2-4*a*c)**0.5)/(2*a)
rootn=(-b-(b**2-4*a*c)**0.5)/(2*a)
28. l=[10.20]
l1=[30,40]
l2=[50,60]
l.append(l2)
print(l)
BB
CCC
DDDD
EEEEE
For i in range(65,70):
Print(chr(i)*(-65+i+1))
30. 10
99
888
7777
66666
for j in range(10,5,-1):
print(j,end='')
print()
31. for i in range(1,100,1):
if i%4==2:
print(i,'mod',4'=2')
i=1
while i<100:
if i%4==2:
print(i,'mod',4'=2')
i+=1
32. x='abcdef'
i='a'
while i in x:
print(i,end='')
33. n=50
i=5
s=0
while i<n:
s+=i
i+=10
print('i'=,i)
print('sum=1',s)
34. x=12
For i in x:
Print(i)
35. x=’abcdef’
i=’i’
while i in x:
print(i,end=’’)
Randrange()
Randint()
i=0
while p[i]1='r':
l=random.randint(0,3)+5
print(p[l],'-')
i+=1
38. str1='sure'
str2='try it'
n1=10
n2=3
print(str1+str2)
print(str1*n2)
print(str1+n1)
print(str2*str1)
a=input()
b=a[::-1]
if b==a:
else:
print('not palidrome')
age=int(input())
if age>=18:
print('eligble')
else:
print('not eligble')
41. nav=['LEFT','FRONT','RIGHT','BACK']
num=random.randint(1,3)
navg=''
for c in range(num,1,-1):
navg=navg+nav[c]
print(navg)
String
a) + b) * c) - d) none of these
A=8/2
B=8//3
print(A,B)
46. print(min(max9false,-3,-4),2,7))
47. Take a two list & write a program that return a lists only
ex:
l1[1,1,2,3,5,8,13,21,34,55,89]
l2=[20,1,2,3,4,5,6,7,8,9,10,11,12,13]
Number.
sqnum=0
num=int(input())
for i in num:
sqnum+=int(i0**2)
print(sqnum)
49. stri=list('Test')
for i in range(len(str1)):
if i==3:
x=int(i)
x+=x-3
str[i]=x
elif str1[i].i.lower():
stri[i]=str1[i].upper()
else:
str1[i]=stri[i]*2
print(str1)
50. a=[1,2,3]
b=[5,6,7]
for i in range(1,3):
a[i-1]=a[i]+1
for i in range(1,3):
print(a[i],end='_')
for i in range(1,3):
b[i-1]=b[i]+1
for i in range(0,3):
print(s[i],end='#')
51. print(25//4+3**1**2*2)
x=Tday.split()
print(x[0],x[3],x[4])
print(Tday.captialize(),Tday.title())
num1,num2=10
while num1%num2=0
num1+=20
num2+=30
Else:
Print(‘hello’)
print(message[ : :-2])
book_dict[‘author’]=’Shiv Khara’
book_dict[‘genre’]=’Motivation’
print(book_dict.items())
56. str=””
name=”9@Days”
for x in name:
if x in ‘aeiou’:
str=str+x.upper()
str=str+”**”
elif is.digit():
pass
else:
str=str+x.lower()
print(str)
57. moves=[11,22,33,44]
Queen=moves
Moves[2]+=22
L=len(moves)
for i in range(L):
print(“Now @”,Queen[L-i-1],’#’,moves[i])
58. tuple1=([7,6],[4,4],[5,9],[3,4],[5,5],[6,2],[8,4])
Listy=list(tuple1)
New_list=[]
tot=0
tot+=value
if elem.cpunt(value)==2:
New_list.append(value)
tot=0
else:
print(tuple(new_list))
59. print(2*7+2**3-2/5+3%4)
Print(S.capitalize(),S.title(),S.lower(),end=’!’)
61. x=’IncredibleIndia’[-2:-7:-1]
print(x,x[2:-2],sep=’$’)
62. x,y=(1,2),(3,4)
y,x=x,y+(2,)
print(x,y)
vibgyor=[[‘V’,’Violet’,[‘I’,’Indigo’],[‘B’,’Blue’],[‘G’,’Green’],[‘Y’,’
Yellow],
[‘O’,’Orange’],[‘R’,’Red’]]
for I in range(3):
first=randint(0,1)
last=randint(1,2)+1
print(vibgyor[last-first],end=’:’)
64. L=[100,212,310]
print(L)
L.extend([33,52])
for I in range(len(L)):
if L[i]%10==0:
L[i]=L[i]/5
elif L%2==0:
L[i]=L[i]//10
else:
L[i]=L[i]%10
print(L)
65. S=’welcome2cs’
N=len(s)
M=’’
for i in range(0,n):
M=M+S[i].upper()
M=M+S[i-1]
elif S[i].isupper():
M=M+S[i].lower()
else:
M=M+’$’
Print(M)
66. i=0
while i<0:
i=i+1
if i==5:
break
print(i,end=’’)
print(x,’#’,end=’’)
sum=0
sum=sum+disc[key]
print(sum)
69. S=”PREboardcs*2024”
j=2
for I in S.split(‘*’):
k=i[ :j]
if k.isupper():
j=j+1
elif k.isdigit():
j=j+2
else:
j=j+3
print(s[j: :j])
70. Text=’Gmail@com’
Len=len(Text)
S=1+x+x^2+x^3+…x^n.
ntext=’’
for i in range(0,Len):
if Text[i].isupper():
ntext=ntext+Text[i].lower()
elif Text[i].isalpha():
ntext=ntext+Text[i].upper()
else:
ntext=ntext+”b”
print(ntext)
print(word.find(‘g’,2))
print(word.find(‘tab’,2,15))
74. List=[2,4,6,8,10]
for i in range(1,5):
List[i-1]=List[i]
for i in range(0,5):
print(List[i],end=’ ’)