Python Quiz
- Get link
- X
- Other Apps
Python Quiz
Quiz
- Which of the following is an invalid statement?
- abc = 1,000,000
- a b c = 1000 2000 3000
- a,b,c = 1000, 2000, 3000
- a_b_c = 1,000,000
- What is the maximum possible length of an identifier?
- 32 characters
- 63 characters
- 79 characters
- None of the above
- Which of the following sorting algorithm for a numerical dataset in Python are correct?
- list = ["1", "4", "0", "6", "9"]
list = [int(i) for i in list]
list.sort()
print (list) - list = ["1", "4", "0", "41", "9"]
list = [int(i)]
list.sort()
print (list) - list = ["1", "4", "0", "6", "9"]
list = [int(i) for i in list]
print (list) - none
- list = ["1", "4", "0", "6", "9"]
- Which statement is correct....??
- Both are Immutable
- Both are Mutable
- List is mutable && Tuple is immutable
- List is immutable && Tuple is mutable
- print(chr(ord('b')+1))
- b
- error
- c
- b+1
- The format function, when applied on a string returns :
- list
- bool
- int
- str
- class test:
def __init__(self):
print "Hello World"
def __init__(self):
print "Bye World"
obj=test()- Hello World
- Compilation Error
- Bye World
- Ambiguity
- a = True
b = False
c = True
if not a or b:
print "a"
elif not a or not b and c:
print "b"
elif not a or b or not b and a:
print "c"
else:
print "d"- a
- b
- c
- d
- a = 8.6
b = 2
print a//b- 4.3
- 4.0
- 4
- error
- If a='cpp', b='buzz' then what is the output of:
c = a-b
print(c)- cpp-buzz
- cppbuzz
- TypeError: unsupported operand
- None of the above
- If a='cpp', b='buzz' then which of the following operation would show 'cppbuzz' as output?
- a+b
- a+''+b
- a+""+b
- All of the above
- What is correct syntax to copy one list into another?
- listA = listB[]
- listA = listB[:]
- listA = listB[]()
- listA = listB
- How to find the last element of list in Python? Assume `bikes` is the name of list.
- bikes[0]
- bikes[-1]
- bikes[lpos]
- bikes[:-1]
- Syntax of constructor in Python?
- def __init__()
- def _init_()
- _init_()
- All of these
- Python allows string slicing. What is the output of below code:
s='cppbuzz chicago'
print(s[3:5])- pbuzz
- buzzc
- bu
- None of these
- Which predefined Python function is used to find length of string?
- length()
- len()
- strlen()
- stringlength()
- Which of the following is correct way to declare string variable in Python?
- fruit = 'banana'
- fruit = "banana"
- fruit = banana
- fruit = (banana)
- Which keyword is used to define methods in Python?
- function
- def
- method
- All of these
- Are nested if-else are allowed in Python?
- Yes
- No
- None
- May be
- Which of the following symbols are used for comments in Python?
- //
- ''
- /**/
- #
- Select the reserved keyword in python
- else
- import
- raise
- All of these
- Which keyword is use for function?
- define
- fun
- def
- function
- Which of the following items are present in the function header?
- function name
- parameter list
- return value
- Both A and B
- What is called when a function is defined inside a class?
- class
- function
- method
- module
- If return statement is not used inside the function, the function will return:
- None
- 0
- Null
- Arbitary value
- What is a recursive function?
- A function that calls other function.
- A function which calls itself.
- Both A and B
- None of the above
- Which of the following is the use of id() function in python?
- Id() returns the size of object.
- Id() returns the identity of the object.
- Both A and B
- None of the above
- Which of the following function headers is correct?
- def fun(a = 2, b = 3, c)
- def fun(a = 2, b, c = 3)
- def fun(a, b = 2, c = 3)
- def fun(a, b, c = 3, d)
- In which part of memory does the system stores the parameter and local variables of funtion call?
- heap
- stack
- Uninitialized data segment
- None
- How is a function declared in Python?
- def function function_name():
- declare function function_name():
- def function_name():
- declare function_name():
- Which one of the following is the correct way of calling a function?
- function_name()
- call function_name()
- ret function_name()
- function function_name()
- Which of the following will print the pi value defined in math module?
- print(pi)
- print(math.pi)
- from math import pi
print(pi) - from math import pi
print(math.pi)
- Which operator is used in Python to import modules from packages?
- .
- *
- ->
- &
- Where is function defined?
- Module
- class
- Another Function
- All of the above
- Lambda is a function in python?
- True
- False
- Lambda is a function in python but user can not use it.
- None
- What is a variable defined outside a function referred to as?
- local
- global
- ststic
- automatic
- What is the output of the following program?
z = lambda x : x * x
print(z(6))- 6
- 36
- 0
- error
- What is the output of the following program?
print(chr(ord(chr(97))))- a
- A
- 97
- error
- Choose the correct option with reference to below Python code?
def fn(a):
print(a)
x=90
fn(x)- x is the formal argument.
- a is the actual argument.
- fn(x) is the function signature.
- x is the actual argument.
- Which one of the following is incorrect?
- The variables used inside function are called local variables.
- The local variables of a particular function can be used inside other functions, but these cannot be used in global space
- The variables used outside function are called global variables
- In order to change the value of global variable inside function, keyword global is used.
Comments