Professional Documents
Culture Documents
1. Which keyword can be used in any place in Python It's a syntax error.
code to tell interpreter “to do Adds string1 to string2 (both must be in numeric
nothing” and move to next instruction format).
skip Correct answer
continue Concatenates string1 and string2.
next 6. Python is compiled language. True or False?
pass True
Correct answer False
pass Correct answer
2. Are there tools available to help find bugs, or False
perform static analysis? 7. Which of these should you include in order to pass
Yes, PyErrs. variables to a script?
Yes, PyChecker and Pylint. from sys import getarg
No, you must find the bugs on your own. from system import argv
Yes, PyStats. from sys import args
Correct answer from sys import argv
Yes, PyChecker and Pylint. Correct answer
3. Python was created by ____________. from sys import argv
James Gosling 8. Which of the following statements is true?
Steve Jobs Python is an interpreted language.
Guido van Rossum Python is a high level programming language.
Google Python is an object-oriented language.
Guido van Rossum All of the above.
What is used to define a block of code (body of loop, Correct answer
function etc.) in Python? All of the above.
Curly braces 9. In Python, 'Hello', is the same as "Hello"
Parenthesis True
Indentation False
Quotation 10.What is the correct file extension for Python files?
4. A Python paragraph comment uses the style .pyth
________. .pt
// comments // .pyt
/ comments / .py
''' comments ''' Correct answer
/# comments #/ .py
Correct answer 11.In Python, a syntax error is detected by the
''' comments ''' ________ at _________.
5. What does the expression string1 + string2 do? compiler/at compile time
Repeats string1 string2 times (string2 must be in interpreter/at runtime
1
25 unlimited length
Error True
Correct answer -6
Answer: a v) Addition
Page
a) int d) -5
Page
Python 2.7.17 (default, Nov 7 2019, 10:07:09) does affect the order of
Page
gives 0. b) 11010100
function bool. Hence the output is false. argument passed to the Boolean function amount
Page
2. What will be the output of the following Python to zero. Else ‘t’ is printed. The
b) 456000 print(“%f”%x)
Page
c) 456 a) 34.00
result in an error. The output of for the format specifier %06d. Hence the output of
Page
this expression is -%5d0 989. Hence this statement this code is:
13. What will be the output of the following Python b) ‘first=0, third=2’
Page
code? c) Error
Explanation: The code shown above converts the c) ‘The {bright} side {of} {life}’
Page
tuple of one or more items. Since single item can be d) none of the mentioned
Page
Answer: b while i in x:
c) a a a a a a … returned.
upper(). x = 'a'
Answer: a Answer: b
Page
Explanation: Loops over the keys of the dictionary. Explanation: Loops over the values.
Answer: a c) 3 3 3 3
Page
None mn22qr22
Page
x str
Page
yz String
2,223,334,445 code?
Page
222,333,444,5 w
error n
Python (‘fff’, ‘bbb’) and (‘fff’, ‘bbb’) Python fff and bin
{0: 'X0', 1: 'X1', 2: 'X2', 3: 'X3', 4: 'X4'} {2: 'check', 3: 'check', 4: 'check'}
Page
dict_items([(1,2,3)]) print(list1[4:6])
list1.insert(3, 5) 123
Page
list1.insert(2, 5) [2, 3, 4]
[5, 7] [2,3,5,7]
Page
Option 4 34566
Page
Correct answer 258. What will be the output of the following code?
print(list1[0]) (1, 2, 3)
Page
print(list1[:2]) {1, 2, 3}
The method sum() doesn’t exist for tuples 298. What will be the output of the following Python
Ans. d. 1 Q69. Fill in the blanks with same word in both places
Page
Q63. Which function returns the length of a list? >>> import __________
list1.pop(3) b. Amit@Sumit@Ravi
Page
print(L) c. Amit@Sumit@Ravi@
print(L[0]) print("YES")
d. Error L1 = [1, 2, 3]
a) olleh d) \x97\x98
2. What will be the output of the following Python highest ascii value.
Page
Answer: c Answer: d
d) String Answer: a
b) John Pan a) cd
b) * abcde * Answer: a
Page
Answer: c list1.index(5)?
Page
6. f(2) d) 12
Page
7. v = f(3) Answer: b
Explanation: Execute in the shell to verify. 3. What will be the output of the following Python
Page
b) [1,3,5,7] code?
Explanation: Append function on lists doesn’t return multiplied, it created references of itself which is
Page
Answer: d digits in a list. Then, sum finds the sum of the digits
integer isn’t mutable. Thus its value doesn’t change. Page 248 of 391
Page
13. What will be the output of the following Python Python Questions and Answers – Tuples – 1
a) 1 dictionary.
b) A 8. What will be the output of the following Python
Page
c) 4 code?
Page 269 of 391 4. What will be the output of the following Python
Python Questions and Answers – Dictionary – 4 code?
Page
Page 271 of 391 12. What will be the output of the following Python
8. If b is a dictionary, what does any(b) do? code?
Page
a) Returns True if any key of the dictionary is true Page 272 of 391
addressed before the overall design too. Explanation: During a Python program execution,
Hence, all modular designs are not because of a top- there are as many as three
Page
code? Answer: a
b) 1 d) 2.0000000000000004
code? math.exp(p)?
b) Either 3 or 4 Answer: b
c) Any integer other than 3 and 4 Explanation: We use the seed function when we
Page
d) Any decimal value between 3 and 4 want to use the same random number
a) True c) 3
b) False d) 1
Page
Answer: a Answer: b
string may be returned. c) you can’t also create your own functions
4. What will be the output of the following Python previously called function.
World,World,World,World,World Answer: c
d) Explanation: If you have some functions with many
Page
b) 14 Explanation: None.
81 d) An exception is thrown
d) None of the mentioned Answer: c
Page
function. print(b,end="")
36. What will be the output of the following Python n=n-1
Page
code? display('z',3)
decimal places has not been specified, the Page 307 of 391
decimal number is rounded off to a whole number. Answer: b
Page
Hence the output will be 5. Explanation: The built-in function any() returns true if
a) 2 b) 0+0j
b) False c) 0
Page
c) -3 d) Error
57. What will be the output of the following Python will be 2000.0. The first function created a floating
function? point number up to 3 decimal places and
Page
list(enumerate([2, 3])) the second function adds 3 zeros after the given
Error
92. What will be the output of the following Python Explanation: In the code shown above, the variable
code? ‘x’ is declared as global within the
Page
def f1(): function. Hence the output is ‘x’. Had the variable ‘x’
print(a) code?
a = "hello" def f(p, q, r):
Page
print(a) global s
f("bitter") locals()
Received input is : Python the next read or write will occur at that many bytes
Explanation: To write a fixed sequence of characters “w” Opens a file for writing only. Overwrites the file
to a file if the file exists. If the file does not
Page
c) f.readline() b) f.read()
use ___________ [6] Which option will be correct for reading file for
read the first line of a text file data.txt? which does not exist?
f=open("data.txt",'r') characters.
Q71. Which of the following mode will opens the file c. append mode
in read, write and binary mode? d. binary and read mode
Page
a. This code will read one line from the file. a. tell( )
b. This code will read all the lines from the file. b. seek( )
Page
c. This code will read only last line from the file. c. put( )
f = open("data.txt","r") Identify the suitable code for blank space in the line
b. d1 f.reads(5)
c. f 2.Which function open file in python?
Page
open()
161
Page