Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
6 views

Python

Uploaded by

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

Python

Uploaded by

johnjadapalli
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

PYTHON

1. What could be the possible output of the following code?


digits = [11, 32, 23, 54, 75, 46, 70]

n=7

required = True a) True

for digit in digits: b) False

if n <= digit: c) Syntax Error

required = False e) None of the above


break Answer : c) Syntax error
print (required)

2. What could be the possible output of the following code?

a)True
b) False

C) Syntax error

d) None of the above

Answer: b) False

3. What is the output of the following code?

a) [44614, 17772, 185556, 255]

b) [12 hours 23 minutes 34 seconds]

c) [4 hours 56 minutes 12 seconos]

d) [23 hours 45 minutes 56 seconds]

Answer: a) [44614, 17772, 185556, 255]


4. what will be the output of the following code?

a) Inside loop b) Inside loop


Inside loop Inside loop
Else block
c) Inside loop d) None of these
Else block
Answer: b) Inside loop
Inside loop

5. Which of the following is not a valid built-in method for type conversion in Python?

a) Int

b) float
c) list

d) char

Answer : d) char

6. Find the following code snippet?

a) 0 1 2 3
b) 0 1 2
c) 0 1 2 3 4

d) 1 2

Answer: b) 0 1 2

7. What is the space complexity of dictionary in python?

a) O(n2)
b) O(log n)
c) O(n)

d) O(n log n)
Answer: c) O(n)
8. what is the purpose of loop in python?
a) To define functions in Python.

b) To handle exceptions and errors in Python.

c) To repeating a block of code multiple times.

d) To perform mathematical operations in Python.

Answer: c) To repeating a block of code multiple times


9. what will be the output of the given code?

a) 105
b) 120
c) 65
d) 75

Answer: c) 65

10. Encapsulation as a feature is available with


a) Procedural Programming
b) Structured Programming
c) Object Oriented Programming
d) None of these
Answer: c) Object Oriented Programming
11. Which of the following objects is/are immutable in Python?
a) String
b) List
c) Tuple
d) String and tuple
Answer: d) String and tuple
12. A class can be defined as
a) an entity consisting of some values
b) A structure that defines methods only
c) A structure that defines the data only
d) the structure that contains the data & the methods
Answer: d) the structure that contains the data & the methods

13. which of the following are the paradigms of the programming?


a) Procedural Programming
b) Object Oriented Programming
c)Structured Programming
d) All of the Above
Answer: d) All the Above

14. what is polymorphism?


Answer: programming it refers to methods/functions/operators with the
same name that can be executed on many objects or classes.

15. Find the output of the following snippet?

Answer: output
myqueue = [1, 2, 3, 4, 5, 6, 7, 8, 9]
16. find the output of the following snippet?
for num in range(15,-6,-4):
print (num)
Answer: output is
15
11
7
3
-1
-5
17. Consider a situation where an incorrect value has been inserted into an
environment variable by another developer and you are asked to remove that
variable's value. The variable's name is "NAME". Which option will you choose
from the listed choices in order to complete the given requirement?
a) remove NAME
b) unset NAME
c) export NAME
d) autoremove NAME
Answer: b) unset NAME
18. When the computer is directed to perform an illegal operation by the
program such as dividing a number by zero then the type of error shown is
a) Syntax Error
b) Logical Error
c) Run Time Error
d) zerodivision Error
Answer: c) Run Time Error
19. Which of the following iterative statement execute at least once?
a) for loop
b) while loop
c) do while loop
d) break
Answer: c) do while loop
20. Allocation and Deallocation of the resource required to execute the
program is done by
a) Operating System
b) Compiler
c) Linker
d) Loader
Answer: a) Operating System
21. The correct sequence of the below steps to reverse the ian song
1 Initiate
2. Get the length of the string
3 Start a loop and then swap the position of the array elements
4 Keep the exchanged positions.
5. Print the reversed string.
6. The string which is to be reversed is declared.
Answer: 1, 6, 3, 4, 5, 2.
22. Read the instructions and complete the program
Kalyani, the process in which Python reclaims unused memory blocks at a
periodic interval is termed as
a) Reclamation
b) Compaction
c) Garbage Collection
d) None of the these
Answer: c) Garbage Collection
23. what is the output of the following snippet?
while (true)
// Some code here
if (some condition)
break the loop
}
}
a) it will run forever
b) It will run till "some condition" is satisfied
c) It will run only if "some condition" is satisfied

--------------------------------------------------------------------------------------------------------------------------

Python Codings:
1) name = input() output:
print ("Hello, " + name) Hello, Doselect

2) a = input(" ") output:


b = input(" ") Do
c = (a+" "+b) Select
print(c) Do Select

3) Find the max length of the string


a=int(input())
b=input()
c=input()
d=input()
Max_num=max(len(b),len(c),len(d))
print(Max_num)

You might also like