Python Basic MCQ
Python Basic MCQ
1. What's the output?
def hello(k):
k = [1]
x = [0]
hello(x)
print(x)
- A: [0]
- B: [1]
- C: [1,0]
- D: [0,1]
2. What's the output?
str1= '{3},{1} and {0}'. format('p','r','i')
print(str1)
- A: Tuple index out of range
- B: i,r and p
- C: ppp,r
- D: None
3. What's the output?
str1= '{1},{1},{2} and {0}'. format('p','r','i')
str2 = '{0}{1}{0}'.format('priya', 'cad')
print(str1,str2)
- A: r,r,i,p priyacad0
- B: r,r,i and p priyacad0
- C: r,r,i and p priyacadpriya
- D: p,p,r and i priyacadpriya
4. What's the output?
a=3
b=3.876
c= -5
str1 = '{0:.4f} {0:3d} {2} {1}'.format(a, b, c)
print(str1)
Here, hash(#) represent spaces.
- A: 3.0000 3 -5 3.876
- B: 3 3.876 -5 3.876
- C: 3.0000 ###3 -5 3.876
- D: 3.0000 ##3 -5 3.876
5. What's the output?
line1='And here you can learn '
line2='You will fall in love with python '
line3='Pyhton is interpreted language '
line4=line1 + line2 + line3
print(line1.find('you'),line4.count('python'))
- A: 9,2
- B: 9 1
- C: (9,1)
- D: True,1