0% found this document useful (0 votes)
54 views5 pages

BCA SemModelMCQs PP 2024

This document contains a set of questions and answers related to Python programming. There are multiple choice questions testing various Python concepts like data types, operators, functions, classes and objects.

Uploaded by

Tridib Bhunia
Copyright
© © All Rights Reserved
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% found this document useful (0 votes)
54 views5 pages

BCA SemModelMCQs PP 2024

This document contains a set of questions and answers related to Python programming. There are multiple choice questions testing various Python concepts like data types, operators, functions, classes and objects.

Uploaded by

Tridib Bhunia
Copyright
© © All Rights Reserved
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/ 5

Model Question Python Programming Very Short Question

1. What is the value of the given expression in python: 10+3**3*2 Ans: 64


2. The mode of python gives instant result of typed statement. Ans: Interactive mode
3. The floor division of two floating point values yields a result of type. Ans: Integer
4. In python comments begin with character. Ans: #
5. An empty statement in Python is . Ans: pass
6. In python defines a block of statements. Ans: Identation
7. What is the output when this code executes: Ans: No output
x=1 while(x<=5):
x+1 print(x)
8. What values are generated when the function range(6,0,-2) is executed? Ans: [6, 4, 2]
9. What will be the output of the following code snippet? Ans: 8
def add(a, b):return a + b

result = add(3, 5)print(result)


10. Strings can be concatenated by using in Python. Ans: '+' operator
11. What is the output when we execute list(“hello”)? Ans: a) [‘h’, ‘e’, ‘l’, ‘l’, ‘o’]
a) [‘h’, ‘e’, ‘l’, ‘l’, ‘o’]
b) [‘hello’]
c) [‘llo’]
d) [‘olleh’]

12. What will be the output of the following Python code snippet? [True/False] Ans: False
d1 = {"john":40, "peter":45}
d2 = {"john":466, "peter":45}r=d1 == d2
print(r)
13. What does the following Python code snippet do? string =
"Hello, World!" print(string.upper())

Ans: Converts “Hello, World!” to uppercase and prints it


14. Suppose t = (1, 2, 4, 3), which of the following is incorrect? Ans: b) t[3] = 45
a) print(t[3])
b) t[3] = 45
c) print(max(t))
d) print(len(t))

15. What is getattr() used for in python?


Ans: getattr(obj,name) is used to get the attribute of an object.

16. What is Instantiation in terms of OOP terminology?


Ans: Creating an instance or object of a class

17. What will be the output of the following Python code?


class Demo:
def init (self): pass

def test(self):
print( name )

obj = Demo() obj.test()


a) Exception is thrown
b) main
c) Demo
d) Test

Ans: Answer: b
Explanation: Since the above code is being run not as a result of an import from another module, the
variable will have value “ main ”.

18. Value 17.25 is equivalent to in exponent form. Ans: 0.1725E2


19. 0128 is a legal literal in python. (True/False) Ans: False
20. Is Python case sensitive when dealing with identifiers? Ans: yes
21. What will be the output?

if 'bar' in {'foo': 1, 'bar': 2, 'baz': 3}:


print(1)print(2)
if 'a' in 'qux':print(3)
print(4)

Ans:
1
2
4
22. What will be the output of the following Python code? Ans: [‘ab’, ‘cd’]
x = ['ab', 'cd'] for i in x:
i.upper() print(x)

23.Which one of the following ifstatements will not execute successfully: a)


if(1,2):
print("Hello")

b) if(1,2): print("Hello")

c) if(1,2):
print("Hello") d) if(1,2):
print("Hello")

Ans: d) if(1,2):
print("Hello")

24. The clause can occur with an if as well as with loops. Ans: else

25. The operator tests if a given value is contained in a sequence or not.


Ans: Membership

26.Which of the following statements about function arguments in Python is true?


a) All arguments must have default values
b) Functions cannot have more than one argument
c) Arguments are passed by value
d) Arguments can have default values
Ans: d) Arguments can have default values

27.What is the purpose of the global keyword in Python?


a) To define a variable inside a function
b) To access a variable outside a function
c) To modify a variable defined in the global scope from within a function
d) To specify a variable as constant
Ans: c) To modify a variable defined in the global scope from within a function
28.Select the correct output of the following String operations: Ans: Welcom PYnative
str1 = 'Welcome'
print (str1[:6] + ' PYnative')
● Welcome PYnative
● WelcomPYnative
● Welcom PYnative
● WelcomePYnative

29. if a=[1,2,3] Ans: Yes, both will generate same list i.e. [1,2,3,1,2,3,1,2,3]
Is a*3 is equivalent to a+a+a?
30.Suppose t = (1, 2, 4, 3), What will t contains after t[3] = 45? Ans:
It will generate error as Tuple is immutable.
31.In the dictionary key and pair which part holds the unique elements only? Ans: Key
1. Key
2. Pair

32.What will be the output of the following Python code? Ans: “Hello World” is displayed
class test:
def init (self,a=""Hello World""):
self.a=a

def display(self):
print(self.a) obj=test()
obj.display()

33.Which of the following statements is most accurate for the declaration x = Circle()?
A. x contains an int value.
B. x contains an object of the Circle type.
C. x contains a reference to a Circle object.
D. You can assign an int value to x.

Ans: C. x contains a reference to a Circle object.

34.What is the output? Ans: 123


class Sales:
def init (self, id):
self.id = id id = 100

val = Sales(123) print


(val.id)
35.Python preloads some commonly used values in an area of memory known as .
Ans: Front loaded dataspace
36. num1=24//4//2 Ans: 3
print(num1)
37.What is the output? Ans: ValueError
num1=int('3.14') print(num1)
38. What is the output?

x = ['ab', 'cd'] for i in x:


x.append(i.upper()) print(x)
Ans: Infinite loop, as new elements are being added to the list in each iteration.

39.What will be the correct output of the following Python code? Ans: a) 1 2 3 4 5 6
i=1
while True:
if i%0O7 == 0:
break print(i) i += 1

a) 1 2 3 4 5 6
b) 1 2 3 4 5 6 7
c) error
d) none of the mentioned

40.What will be the output of the following Python code?


True = False while True:
print(True) break

Ans: SyntaxError, True is a keyword and it’s value cannot be changed.

41.What will be the output of the following Python code?


x = ['ab', 'cd'] for i in x:
i.upper() print(x)

Ans: [‘ab’, ‘cd’]


The function upper() does not modify a string in place, it returns a new string which isn’t being
stored anywhere.
42.What is the output of the add()function call Ans: Syntax Error
def add(a, b): return a+5, b+5

result = add(3, 2)print(result)

43.What will be the output of the following code snippet?

x=5

def modify():global x
x = 10

modify()print(x)

Ans: 10
Explanation: The function modifymodifies the global variable x, changing its value to 10.

44.Select the correct output of the following String operations Ans: b) 6


str1 = "my isname isisis jameis isis bond";sub = "is";
print(str1.count(sub, 4))
a) 5
b) 6
c) 7

45.Choose the correct function to get the character from ASCII number

a) ascii(number) Ans: c) chr(number)


b) char(number)
c) chr(number)

46. Suppose list1 is [2, 33, 222, 14, 25], What is list1[:-1]? Ans: [2, 33, 222, 14]

47.What will be the output of the following Python code? Ans: c) [1, 4, 8]
1. >>>t = (1, 2, 4, 3, 8, 9)
2. >>>[t[i] for i in range(0, len(t), 2)]
a) [2, 3, 9]
b) [1, 2, 4, 3, 8, 9]
c) [1, 4, 8]
d) (1, 4, 8)

48.How will you create an empty dictionary?


Ans: DICT={} will create an empty dictionary, where DICT is the name of the dictionary.

49.Which of the following can be used to invoke the init method in B from A, where A is a
subclass of B?
A. super(). init () Ans: A. super(). init ()
B. super(). init (self)

50.What is the output? Ans: False


True
If 4+5=10:
print("True") else
print("False") print("True")

You might also like