Python Paper 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Name - Total Marks – 50 Marks Obtained –

Hi-Rel Info Genesis Centre Subject – Programming and Problem Solving through Python
(M3-R5.1)
1. Who developed Python Programming Language? Addition, Subtraction
a) Wick van Rossum c) Rasmus Lerdorf b) Exponential, Parentheses, Division, Multiplication,
b) Guido van Rossum d) Kevin Ashton Addition, Subtraction
2. Which type of Programming does Python support? c) Parentheses, Exponential, Multiplication, Division,
a) object-oriented programming Subtraction, Addition
b) structured programming d) Parentheses, Exponential, Multiplication, Division,
c) functional programming Addition, Subtraction

s
d) all of the mentioned 12. What will be the output of the following Python code

i
3. Is Python case sensitive when dealing with snippet if x=1?

s
identifiers?
X << 2
a) No c) Yes

4.
b) Machine dependent d) None
Which of the following is the correct extension of the
a) 4

n
b) 2

e c) 1 d) 8
13. Which of the following is true for variable names in

e
Python file? Python?
a) .python c) .pl a) underscore and ampersand are the only two
b) .py d) .p

G
special characters allowed
5. Is Python code compiled or interpreted? b) unlimited length
a) Python code is both compiled and interpreted

o
c) all private members must have leading and trailing
b) Python code is neither compiled nor interpreted

f
underscores
c) Python code is only compiled

e
d) none of the mentioned

6.

I n
d) Python code is only interpreted

r
All keywords in Python are in _________
a) Capitalized

t c) lower case
14. What are the values of the following Python
expressions?

7.
l
b) UPPER CASE

e n
d) None
What will be the value of the following Python
expression?

e
>>>2**(3**2)
>>>(2**3)**2
>>>2**3**2

i -
4+3%5
R
a) 7
C
b) 2 c) 4 d) 1
8. Which of the following is used to define a block of
a) 512, 64, 512
b) 512, 512, 512
c) 64, 512, 64
d) 64, 64, 64

H
code in Python language?
a) Indentation
b) Brackets
c) Key
d) All of the above
9. Which of the following character is used to give
single-line comments in Python?
15. Which of the following is the use of id() function in
python?
a) Every object doesn’t have a unique id
b) Id returns the identity of the object
c) All of the mentioned
a) // b) # c) ! d) /* d) None of the mentioned
10. What will be the output of the following Python 16. What will be the output of the following Python
code? function?

i = 1 min(max(False,-3,-4), 2,7)
while True:
a) -4 b) -3 c) 2 d) False
if i%3 == 0:
break 17. What will be the output of the following Python
print(i) function?
len(["hello",2, 4, 6])
i + = 1
a) 1 2 3 c) error a) Error b) 6 c) 4 d) 3
b) 1 2 d) none of the above
11. What is the order of precedence in python?
a) Exponential, Parentheses, Multiplication, Division,
18. What will be the output of the following Python code 26. What will be the output of the following Python
snippet? code?
for i in [1, 2, 3, 4][::-1]: x = 'abcd'
print(i, end=' ') for i in range(len(x)):
print(i)
a) 4 3 2 1 b) error
c) 1 2 3 4 d) none of the above a) Error c) 1 2 3 4
19. What will be the output of the following Python b) a b c d d) 0 1 2 3
statement? 27. Which of the following is a Python tuple?
a) {1, 2, 3} c) {}
>>>"a"+"bc"
b) [1, 2, 3] d) (1, 2, 3)
a) bc b) abc c) a d) bca 28. What is output of print(pow(3, 2))?

s
20. What arithmetic operators cannot be used with a) 9.0 c) None

i
strings in Python? b) 9 d) none of the above

s
a) * b) – c) + d) All of the mentioned 29. Which of the following is the use of ord() function in

e
21. What will be the output of the following Python python?
code? a) Returns the character value

print("abc. DEF".capitalize())

a) Abc. def c) abc. Def


e n
b) Returns the ordinal value
c) Returns the ASCHII value
d) None of the mentioned

G
30. What will be the output of the following Python
b) Abc. Def d) ABC. DEF
code?
22. To add a new element to a list we use which Python

o
command? print('xyyzxxyxyy'.lstrip('xyy'))

f
a) list1.addEnd(5)
b) list1.addLast(5)

n
c) list1.append(5)

r e
a) error
b) z
c) zxxyxyy
d) zxxy

l I
d) list1.add(5)

t
23. What will be the output of the following Python

n
31. Which of the following is a Python list?
a) 1 , 2 , 3
b) Both a and c
c) (1,2,3)
d) none

e
code?
32. Suppose L1 = (1,2,4,3) , which of the following is

- R C
>>>list1[0] = 4e
>>>list1 = [1, 3]
>>>list2 = list1
incorrect ?
a) print(t[3])
b) print(max(t))
c) t[3] = 45
d) print(len(L1))

Hi
>>>print(list2)

a) [1, 4]
b) [1, 3, 4]
c) [4, 3]
d) [1, 3]
24. What is the maximum possible length of an identifier
in Python?
33. What will be the output of the following code ?

>>> t= (1,2,4,3)
>>> t [ 1 : 3 ]

a) (1,2) c) (1,2,4)
a) 79 Characters c) 32 Characters b) (2,4) d) (2,4,3)
b) 63 Characters d) none 34. What will be the output of the following code?
25. What will be the output of the following Python
program? >>> t = (1,2,4,3)
>>> t [ 1 : -1 ]
i = 0
while i < 5:
print(i) a) (1,2) c) (1,2,4)
i += 1 b) (2,4) d) (2,4,3)
if i == 3: 35. What will be the output of the following code?
break
else: >>> t = ( 1 , 2 , 4 , 3 , 8 ,9 )
print(0) >>> [ t [ i ] for i in range(0, len(t), 2) ]
a) Error c) 0 1 2 0
a) [2,3,9] c) [1,2,4,3,8,9]
b) 0 1 2 d) none
b) [1,4,8] d) (1,4,8)
36. What will be the output of the following code?
39. Suppose d = { “john” : 40 , “peter” : 45 } . To obtain
>>> d = { “john” : 40 , “peter” : 45}
the number of entries the number of entries in
>>> d[“john”]
dictionary which command do we use ?
a) 40 c) 45 a) d.size() c) len(d)
b) “john” d) “peter” b) size(d) d) d.len()
37. What will be the output of the following code? 40. What will be the output of the following Python code
snippet ?
>>> d = { “john” : 40 , “peter” : 45}
>>> “john” in d >>> d1 = {"john":40, "peter":45}
>>> list( d.keys() )
a) True c) False
a) [“john”, “peter”]

s
b) None d) Error

i
38. What will be the output of the following code? b) [“john”:40, “peter”:45]

s
c) (“john”, “peter”)
>>> d1 = {"john":40, "peter":45}
d) (“john”:40, “peter”:45)
>>> d2 = {"john":466, "peter":45}
>>> d1 == d2

n e
a) True
b) None

G
c) False
d) Error
e
Q . Write a Python program to find weather the number entered by user is an Armstrong Number or not.

o
Display the message accordingly. ( Use while statement )

f
3 3 3
{ 153 => 1 + 5 + 3 => 1 + 125 + 27 => 153 . Power is decided on the basis of number of digits. }

I n t r e
e l e n
i - R C
H

You might also like