0% found this document useful (0 votes)
113 views

Python MCQ

The document contains 13 multiple choice questions about Python concepts like data types, operators, conditional statements, strings, lists, and comments. The questions cover core Python topics like keywords, identifiers, concatenating strings, accessing list elements, and boolean logic in conditional statements.

Uploaded by

Samyami Sanketh
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
113 views

Python MCQ

The document contains 13 multiple choice questions about Python concepts like data types, operators, conditional statements, strings, lists, and comments. The questions cover core Python topics like keywords, identifiers, concatenating strings, accessing list elements, and boolean logic in conditional statements.

Uploaded by

Samyami Sanketh
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

PYTHON – MCQ

1.Which of the following are valid if/else statements in


Python, assuming x and y are defined appropriately:
a) if x < y: if x > 10: print('foo')

b) if x < y: print('foo'); print('bar'); print('baz')

c) if x < y: d) if x < y:
print('foo') print('foo')
elif y < x: else:
print('bar') print('bar')
else:
print('baz')
2. All keywords in Python are in
A. lower case
B. UPPER CASE
C. Capitalized
D. None of the mentioned

3. What is the maximum possible length of an identifier?

A. 31 characters
B. 63 characters
C. 79 characters
D. none of the mentioned
4. Which of the following is an invalid statement?

A. abc = 1,000,000
B. a b c = 1000 2000 3000
C. a,b,c = 1000, 2000, 3000
D. a_b_c = 1,000,000

5. Which of these in not a core datatype?


A. Lists
B. Dictionary
C. Tuples
D. Class
6. Suppose a list with name test, contains 10 elements. You
can get the 5th element from the test list using:

A) test[5] C) test['5']

B) test[4] D) test['4']

7. What is the output of the following program?

language = ['P', 'y', 't', 'h', 'o', 'n']


print(language[:-4])

A) 'Py' C) ['P', 'y', 't', 'h', 'o']

B) ['P', 'y'] D) [-4]


8. What is used to concatenate two strings in Python?
A) .
B) ,
C) +
D) strcat()

9. Select the reserved keyword in python


A) else
B) import
C) raise
D) All of these
10. Which of the following symbols are used for comments in Python?
A) //
B) ''
C) /**/
D) #

11. Which of the following is correct way to declare string


variable in Python?
A) fruit = 'banana'
B) fruit = "banana"
C) fruit = banana
D) fruit = (banana)
13. a = True
12) a = 8.6 b = False
b=2 c = True
print a/b
if not a or b:
A) 4.3 print "a"
B) 4.0 elif not a or not b and c:
C) 4 print "b"
D) compilation error elif not a or b or not b and
a:
print "c"
else:
print "d“

A) a C) c
B) b D) d

You might also like