Is Python code compiled or interpreted?
1. Python code is both compiled and interpreted
2. Python code is neither compiled nor interpreted
3.Python code is only compiled
4.Python code is only interpreted
What is output of print(math.pow(3, 2))?
1.9.0
2.None
3.9
4.none of the mentioned
What is the maximum possible length of an identifier in Python?
1.79 characters
2.31 characters
3.63 characters
4.none of the mentioned
What will be the output of the following Python code? '%s' %((1.23,),)
1. ‘(1.23,)’
2.1.23,
3. (,1.23)
4.‘1.23’
What will be the output of the following Python code? class tester: def __init__(self, id): self.id = str(id) id="224" >>>temp = tester(12) >>>print(temp.id)
1. 12
2.224
3.None
4. error
What will be the output of the following Python code? print('*', "abcde".center(6), '*', sep='')
1.* abcde *
2. *abcde *
3. * abcde*
4.* abcde *
What will be the output of the following Python code? x = [[0], [1]] print((' '.join(list(map(str, x))),))
1. 01
2. [0] [1]
3. (’01’)
4.(‘[0] [1]’,)
What will be the output of the following Python program? def foo(x): x[0] = ['def'] x[1] = ['abc'] return id(x) q = ['abc', 'def'] print(id(q) == foo(q))
1. Error
2.None
3.False
4.True
Which of the following character is used to give single-line comments in Python?
1. //
2.#
3. !
4. /*
Which of these is the definition for packages in Python?
1. A set of main modules
2. A folder of python modules
3.A number of files containing Python definitions and statements
4.A set of programs making use of Python modules
All keywords in Python are in _____
1.Capitalized
2.lower case
3.UPPER CASE
4.None of the mentioned
hich function is called when the following Python program is executed? f = foo() format(f)
1. str()
2. format()
3.__str__()
4. __format__()
Python supports the creation of anonymous functions at runtime, using a construct called __________
1. pi
2.anonymous
3.lambda
4.none of the mentioned
The process of pickling in Python includes ______
1. conversion of a Python object hierarchy into byte stream
2.conversion of a datatable into a list
3. conversion of a byte stream into Python object hierarchy
4.conversion of a list into a datatable
To add a new element to a list we use which Python command?
1. list1.addEnd(5)
2. list1.addLast(5)
3. list1.append(5)
4. list1.add(5)
What are the two main types of functions in Python?
1.System function
2.Custom function
3.Built-in function & User defined function
4. User function
What does pip stand for python?
1.unlimited length
2. all private members must have leading and trailing underscores
3.Preferred Installer Program
4. None of the mentioned
What does pip stand for python?
1.unlimited length
2. all private members must have leading and trailing underscores
3.Preferred Installer Program
4. None of the mentioned
What is the order of namespaces in which Python looks for an identifier?
1.Python first searches the built-in namespace, then the global namespace and finally the local namespace
2. Python first searches the built-in namespace, then the local namespace and finally the global namespace
3.Python first searches the local namespace, then the global namespace and finally the built-in namespace
4.Python first searches the global namespace, then the local namespace and finally the built-in namespace
What is the order of precedence in python?
1.Exponential, Parentheses, Multiplication, Division, Addition, Subtraction
2. Exponential, Parentheses, Division, Multiplication, Addition, Subtraction
3.Parentheses, Exponential, Multiplication, Division, Subtraction, Addition
4.Parentheses, Exponential, Multiplication, Division, Addition, Subtraction
What will be the output of the following Python code snippet? z=set('abc$de') 'a' in z
1. Error
2.True
3. False
4.No output
What will be the output of the following Python code? D=dict(p='san', q='foundry') '{p}{q}'.format(**D)
1.Error
2. sanfoundry
3.san foundry
4. {‘san’, ‘foundry’}
What will be the output of the following Python code? '%.2f%s' % (1.2345, 99)
1. ‘1.2345’, ‘99’
2. ‘1.2399’
3.‘1.234599’
4.1.23, 99
What will be the output of the following Python code? 'The {} side {1} {2}'.format('bright', 'of', 'life')
1. Error
2. ‘The bright side of life’
3. ‘The {bright} side {of} {life}’
4. No output
What will be the output of the following Python code? '{0:f}, {1:2f}, {2:05.2f}'.format(1.23456, 1.23456, 1.23456)
1. Error
2. ‘1.234560, 1.22345, 1.23’
3.No output
4.‘1.234560, 1.234560, 01.23’
What will be the output of the following Python code? '{a}{b}{a}'.format(a='hello', b='world')
1. ‘hello world’
2.‘hello’ ‘world’ ‘hello’
3. ‘helloworldhello’
4. ‘hello’ ‘hello’ ‘world’
What will be the output of the following Python code? def foo(): try: return 1 finally: return 2 k = foo() print(k)
1.error, there is more than one return statement in a single try-finally block
2.3
3. 2
4.1
What will be the output of the following Python code? hex(255), int('FF', 16), 0xFF
1. [0xFF, 255, 16, 255]
2. (‘0xff’, 155, 16, 255)
3.Error
4. (‘0xff’, 255, 255)
What will be the output of the following Python code? i = 1 while True: if i%3 == 0: break print(i) i + = 1
1.1 2 3
2. error
3. 1 2
4.none of the mentioned
What will be the output of the following Python code? print("Hello {0[0]} and {0[1]}".format(('foo', 'bin')))
1.Hello (‘foo’, ‘bin’) and (‘foo’, ‘bin’)
2.Error
3.Hello foo and bin
4. None of the mentioned
What will be the output of the following Python code? x = 'abcd' for i in range(len(x)): print(i)
1.error
2. 1 2 3 4
3. a b c d
4. 0 1 2 3
What will be the output of the following Python code? x = 'abcd' for i in x: print(i.upper())
1. a B C D
2.a b c d
3.error
4.A B C D
What will be the output of the following Python expression? round(4.576)
1.4
2. 4.6
3. 5
4.4.5
What will be the output of the following Python function? len(["hello",2, 4, 6])
1.Error
2.6
3.4
4.3
What will be the output of the following Python function? min(max(False,-3,-4), 2,7)
1.-4
2.-3
3. 2
4. False
What will be the output of the following Python program? def addItem(listParam): listParam += [1] mylist = [1, 2, 3, 4] addItem(mylist) print(len(mylist))
1.5
2.8
3.2
4.1
What will be the output of the following Python program? i = 0 while i < 5: print(i) i += 1 if i == 3: break else: print(0)
1.error
2.0 1 2 0
3. 0 1 2
4. None of the mentioned
What will be the output of the following Python statement? >>>"a"+"bc"
1.bc
2.abc
3. a
4.bca
What will be the output of the following two codes? i. '{0}'.format(4.56) ii. '{0}'.format([4.56,])
1. ‘4.56’, ‘4.56,’
2. ‘4.56’, ‘[4.56]’
3.4.56, [4.56,]
4. 4.56, [4.56,]
Which keyword is used for function in Python language?
1.Function
2. Def
3.Fun
4.Define
Which of the following functions can help us to find the version of python that we are currently working on?
1. sys.version(1)
2. sys.version(0)
3.sys.version()
4.sys.version
Which of the following functions is a built-in function in python?
1. factorial()
2.print()
3.seed()
4.sqrt()
Which of the following is a feature of Python DocString?
1. In Python all functions should have a docstring
2.Docstrings can be accessed by the __doc__ attribute on objects
3.It provides a convenient way of associating documentation with Python modules, functions, classes, and methods
4.all of the mentioned
Which of the following is a Python tuple?
1. {1, 2, 3}
2. {}
3. [1, 2, 3]
4.(1, 2, 3)
Which of the following is not a core data type in Python programming?
1. Tuples
2. Lists
3.Class
4. Dictionary
Which of the following is the correct extension of the Python file?
1. .python
2..pl
3..py
4. .p
Which of the following is the truncation division operator in Python?
1. |
2. //
3. /
4.%
Which of the following is the use of id() function in python?
1. Every object in Python doesn’t have a unique id
2.In Python Id function returns the identity of the object
3.None of the mentioned
4.all of the mentioned
Which of the following is true for variable names in Python?
1. underscore and ampersand are the only two special characters allowed
2.unlimited length
3.all private members must have leading and trailing underscores
4.none of the mentioned
Which of the following is used to define a block of code in Python language?
1. Indentation
2.Key
3. Brackets
4.All of the mentioned
Which of the following statements is used to create an empty set in Python?
1. ( )
2. [ ]
3. { }
4.set()
Which one of the following is not a keyword in Python language?
1.pass
2.eval
3.assert
4.nonlocal
Which one of the following is the use of function in python?
1.Functions don’t provide better modularity for your application
2.you can’t also create your own functions
3.Functions are reusable pieces of programs
4.all of the mentioned
Which type of Programming does Python support?
1.object-oriented programming
2. structured programming
3. functional programming
4.all of the mentioned
Who developed Python Programming Language?
1.Wick van Rossum
2.Rasmus Lerdorf
3.Guido van Rossum
4.Niene Stom