PYTHON PROGRAMMING ONE MARKS
1. Who developed Python Programming Language?
a) Wick van Rossum
b) Rasmus Lerdorf
c) Guido van Rossum
d) Niene Stom
2. Which type of Programming does Python support?
a) object-oriented programming
b) structured programming
c) functional programming
d) all of the mentioned
3. Is Python case sensitive when dealing with identifiers?
a) no
b) yes
c) machine dependent
d) none of the mentioned
4. Is Python code compiled or interpreted?
a) Python code is both compiled and interpreted
b) Python code is neither compiled nor interpreted
c) Python code is only compiled
d) Python code is only interpreted
5. All keywords in Python are in _________
a) Capitalized
b) lower case
c) UPPER CASE
d) None of the mentioned
6. Which of the following is used to define a block of code in Python language?
a) Indentation
b) Key
c) Brackets
d) All of the mentioned
7. Which keyword is used for function in Python language?
a) Function
b) def
c) Fun
d) Define
8. Which of the following character is used to give single-line comments in Python?
a) //
b) #
c) !
d) /*
9. What will be the output of the following Python code?
i = 1
while True:
if i%3 == 0:
break
print(i)
i + = 1
a)1 2 3
b) error
c) 1 2
d) none of the mentioned
PYTHON PROGRAMMING ONE MARKS
[Link] is the order of precedence in python?
a) Exponential, Parentheses, Multiplication, Division, Addition, Subtraction
b) Exponential, Parentheses, Division, Multiplication, Addition, Subtraction
c) Parentheses, Exponential, Multiplication, Addition, Division, Subtraction
d) Parentheses, Exponential, Multiplication, Division, Addition, Subtraction
11. What will be the output of the following Python code snippet if x=1?
x<<2
a) 4
b) 2
c) 1
d) 8
[Link] of the following functions is a built-in function in python?
a) factorial()
b) print()
c) seed()
d) sqrt()
13. What will be the output of the following Python function?
min(max(False,-3,-4), 2,7)
a) -4
b) -3
c) 2
d) False
[Link] of the following is not a core data type in Python programming?
a) Tuples
b) Lists
c) Class
d) Dictionary
[Link] will be the output of the following Python expression if x=56.236?
print("%.2f"%x)
a) 56.236
b) 56.23
c) 56.0000
d) 56.24
[Link] will be the output of the following Python function?
len(["hello",2, 4, 6])
a) Error
b) 6
c) 4
d) 3
[Link] will be the output of the following Python statement?
1. >>>"a"+"bc"
A)bc
b) abc
PYTHON PROGRAMMING ONE MARKS
c) a
d) bca
[Link] arithmetic operators cannot be used with strings in Python?
a) *
b) –
c) +
d) All of the mentioned
[Link] will be the output of the following Python code?
print("abc. DEF".capitalize())
a)Abc. def
b) abc. def
c) Abc. Def
d) ABC. DEF
[Link] of the following statements is used to create an empty set in Python?
a) ( )
b) [ ]
c) { }
d) set()
[Link] add a new element to a list we use which Python command?
a) [Link](5)
b) [Link](5)
c) [Link](5)
d) [Link](5)
22. Which of the following Python statements will result in the output: 6?
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
a) A[2][1]
b) A[1][2]
c) A[3][2]
d) A[2][3]
23. What is the maximum possible length of an identifier in Python?
a) 79 characters
b) 31 characters
c) 63 characters
d) none of the mentioned
[Link] are the two main types of functions in Python?
a) System function
b) Custom function
c) Built-in function & User defined function
d) User function
[Link] of the following is a Python tuple?
a) {1, 2, 3}
b) {}
c) [1, 2, 3]
d) (1, 2, 3)
PYTHON PROGRAMMING ONE MARKS
[Link] will be the output of the following Python expression?
round(4.576)
a) 4
b) 4.6
c) 5
d) 4.5
27. The readlines() method returns ____________
a) str
b) a list of lines
c) a list of single characters
d) a list of integers
28. To read the remaining lines of the file from a file object infile, we use ____________
a) [Link](2)
b) [Link]()
c) [Link]()
d) [Link]()
[Link] read the next line of the file from a file object infile, we use ____________
a) [Link](2)
b) [Link]()
c) [Link]()
d) [Link]()
30. To open a file c:\[Link] for reading, we use _____________
a) infile = open(“c:\[Link]”, “r”)
b) infile = open(“c:\\[Link]”, “r”)
c) infile = open(file = “c:\[Link]”, “r”)
d) infile = open(file = “c:\\[Link]”, “r”)
[Link] open a file c:\[Link] for writing, we use ____________
a) outfile = open(“c:\[Link]”, “w”)
b) outfile = open(“c:\\[Link]”, “w”)
c) outfile = open(file = “c:\[Link]”, “w”)
d) outfile = open(file = “c:\\[Link]”, “w”)
32. Which of the following is not a valid mode to open a file?
a) ab
b) rw
c) r+
d) w+
[Link] do you get the name of a file from a file object (fp)?
a) [Link]
b) [Link](name)
c) self.__name__(fp)
d) fp.__name__()
34. Which of the following is not a valid attribute of a file object (fp)?
a) [Link]
b) [Link]
c) [Link]
d) [Link]
PYTHON PROGRAMMING ONE MARKS
35. How do you close a file object (fp)?
a) close(fp)
b) fclose(fp)
c) [Link]()
d) fp.__close__()
[Link] do you delete a file?
a) del(fp)
b) [Link]()
c) [Link](‘file’)
d) [Link](‘file’)
37. What is the type of inf?
a) Boolean
b) Integer
c) Float
d) Complex
38. Which of the following is incorrect?
a) x = 30963
b) x = 0x4f5
c) x = 19023
d) x = 03964
[Link] of the following is incorrect?
a) float(‘inf’)
b) float(‘nan’)
c) float(’56’+’78’)
d) float(’12+34′)
[Link] does 3 ^ 4 evaluate to?
a) 81
b) 12
c) 0.75
d) 7
41. What will be the output of the following Python code?
def f1():
x=15
print(x)
x=12
f1()
a) Error
b) 12
c) 15
d) 1512
[Link] will be the output of the following Python code?
def f1(a,b=[]):
[Link](a)
return b
print(f1(2,[3,4]))
a) [3,2,4]
b) [2,3,4]
PYTHON PROGRAMMING ONE MARKS
c) Error
d) [3,4,2]
[Link] will be the output of the following Python code?
d = {0: 'a', 1: 'b', 2: 'c'}
for i in d:
print(i)
a)0 1 2
b) a b c
c) 0 a 1 b 2 c
d) none of the mentioned
44. . Which of the following functions is a built-in function in python?
a) seed() b) sqrt() c) factorial() d) print()
[Link] are the outcomes of the following functions?
chr(‘97’)
chr(97)
a) a and Erro b) ‘a’ c) Error d) Errors
46. Which of the following functions accepts only integers as arguments?
a) ord() b) min() c) chr() d) any()
[Link] of the following is the use of function in python?
a) Functions are reusable pieces of programs
b) Functions don’t provide better modularity for your application
c) you can’t also create your own functions
d) All of the mentioned