Python Objective Questions For Beginners - CppBuzz
Python Objective Questions For Beginners - CppBuzz
Home C C++ Java Python Perl PHP SQL JavaScript Linux Online Test
Question: 1
(A) else
(B) import
(C) raise
(D) All of these
Show Ans
Ans: D
Forum
Level: Beginner Category: other
[Posted by: Admin | Chicago, USA]
Question: 2
Which of the
following symbols are
(A) //
(B) ''
(C) /**/
(D) #
Show Ans
Ans: D
Forum
Level: Beginner Category: other
[Posted by: Admin | Chicago, USA]
Question: 3
(A) Yes
(B) No
Show Ans
Ans: A
Forum
Level: Beginner Category: conditional
[Posted by: Admin | Chicago, USA]
Question: 4
(A) function
(B) def
(C) method
(D) All of these
Show Ans
Ans: B
Forum
Level: Beginner Category: methods
[Posted by: Admin | Chicago, USA]
Question: 5
Which of the
following is correct
Show Ans
Ans: A
Forum
Level: Beginner Category: variables
[Posted by: Admin | Chicago, USA]
Question: 6
Which predefined
Python function is
(A) length()
(B) len()
(C) strlen()
(D) stringlength()
Show Ans
Ans: B
Forum
Level: Beginner Category: methods
[Posted by: Admin | Chicago, USA]
Question: 7
s='cppbuzz chicago'
(A) pbuzz
(B) buzzc
(C) bu
(D) None of these
Show Ans
Ans: C
Forum
Level: Beginner Category: methods
[Posted by: Admin | Chicago, USA]
Question: 8
Syntax of constructor
in Python?
Show Ans
Ans: A
Forum
Level: Beginner Category: classesAndobjects
[Posted by: Admin | Chicago, USA]
Question: 9
(A) bikes[0]
(B) bikes[-1]
(C) bikes[lpos]
(D) bikes[:-1]
Show Ans
Ans: B
Forum
Level: Beginner Category: other
[Posted by: Admin | Chicago, USA]
Question: 10
What is correct
syntax to copy one
Show Ans
Ans: B
Forum
Level: Practionar Category: other
[Posted by: Admin | Chicago, USA]
Question: 11
If a='cpp', b='buzz'
then which of the
(A) a+b
(B) a+''+b
(C) a+""+b
(D) All of the above
Show Ans
Ans: D
Forum
Level: Beginner Category: other
[Posted by: Admin | Chicago, USA]
Question: 12
If a='cpp', b='buzz'
then what is the
output of:
c = a-b
(A) cpp-buzz
(B) cppbuzz
(C) TypeError: unsupported operand
(D) None of the above
Show Ans
Ans: C
Forum
Level: Beginner Category: other
[Posted by: Admin | Chicago, USA]
Question: 13
a = 8.6
b = 2
print a//b
(A) 4.3
(B) 4.0
(C) 4
(D) compilation error
Show Ans
Ans: B
Forum
Level: Beginner Category: operators
[Posted by: Harshit Gupta | Allahabad,India]
Question: 14
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) a
(B) b
(C) c
(D) d
Show Ans
Ans: B
Forum
Level: Beginner Category: variables
[Posted by: Harshit Gupta | Allahabad,India]
Question: 15
class test:
def
__init__(self):
print "Hello
World"
def
__init__(self):
print "Bye
Show Ans
Ans: C
Forum
Level: Beginner Category: variables
[Posted by: Harshit Gupta | Allahabad,India]
Question: 16
(A) list
(B) bool
(C) int
(D) str
Show Ans
Ans: D
Forum
Level: Beginner Category: variables
[Posted by: Harshit Gupta | Allahabad,India]
Question: 17
(A) list
(B) bool
(C) int
(D) str
Show Ans
Ans: D
Forum
Level: Beginner Category: methods
[Posted by: Harshit Gupta | Allahabad,India]
Question: 18
print(chr(ord('b')+1)
)
(A) b
(B) syntax error
(C) c
(D) b+1
Show Ans
Ans: C
Forum
Level: Beginner Category: other
[Posted by: Harshit Gupta | Allahabad,India]
Question: 19
Which statement is
correct....??
Show Ans
Ans: A
Forum
Level: Beginner Category: variables
[Posted by: Shani pratap singh | Pune]
Question: 20
What is PEP8?
PEP8 is a set of
coding guidelines in
Show Ans
Ans: A
Forum
Level: Beginner Category: other
[Posted by: Admin | Chicago, USA]
Question: 21
State the difference
between tuples and
lists in Python.
Show Ans
Ans: A
Forum
Level: Practionar Category: other
[Posted by: Admin | Chicago, USA]
Question: 22
Write a sorting
algorithm for a
numerical dataset in
Python
Show Ans
Ans: A
Forum
Level: Practionar Category: arrays
[Posted by: Admin | Chicago, USA]
Question: 23
Show Ans
Ans: A
Forum
Level: Practionar Category: other
[Posted by: Admin | Chicago, USA]
Question: 24
(A) 32 characters
(B) 63 characters
(C) 79 characters
(D) None of the above
Show Ans
Ans: D
Forum
Level: Beginner Category: variables
[Posted by: Admin | Chicago, USA]
Question: 25
Which of the
following is an
Show Ans
Ans: B
Forum
Level: Expert Category: variables
[Posted by: Admin | Chicago, USA]
Question: 26
(A) Error
(B) 25
(C) None
(D) 2
Show Ans
Ans: B
Forum
Level: Practionar Category: arrays
[Posted by: Admin | Chicago, USA]
Question: 27
To open a file
c:cppbuzz.txt for
Show Ans
Ans: C
Forum
Level: Practionar Category: filehandling
[Posted by: Admin | Chicago, USA]
Question: 28
What is dictionary in
Python?
Ans:
The built-in
Show Ans
Ans: A
Forum
Level: Beginner Category: other
[Posted by: Admin | Chicago, USA]
Question: 29
Which of the
following date format
should be used in
place of ???
import time
(A) “%d/%m/%Y”
(B) “%d/%M/%y”
(C) “%D/%M/%Y”
(D) “%d/%m/%y”
Show Ans
Ans: A
Forum
Level: Practionar Category: regularexpressions
[Posted by: Admin | Chicago, USA]
Question: 30
(A) Class
(B) List
(C) Dictionary
(D) Tuple
Show Ans
Ans: A
Forum
Level: Beginner Category: classesAndobjects
[Posted by: Admin | Chicago, USA]
Question: 31
(A) 13
(B) 2
(C) 15
(D) None of these
Show Ans
Ans: A
Forum
Level: Beginner Category: variables
[Posted by: Admin | Chicago, USA]
Question: 32
How following
evaluates in Python?
round(0.5) –
(A) 0
(B) 1
(C) 2
(D) 0.5
Show Ans
Ans: C
Forum
Level: Beginner Category: variables
[Posted by: Admin | Chicago, USA]
Question: 33
>>>str="cppbuzz"
(A) uzz
(B) cpp
(C) buzz
(D) cppb
Show Ans
Ans: B
Forum
Level: Beginner Category: variables
[Posted by: Admin | Chicago, USA]
Question: 34
Is it possible to use
round function
(A) Yes
(B) No
Show Ans
Ans: A
Forum
Level: Practionar Category: methods
[Posted by: Admin | Chicago, USA]
Question: 35
(A) Tuple
(B) Array
(C) Dictionary
(D) List
Show Ans
Ans: D
Forum
Level: Practionar Category: variables
[Posted by: Admin | Chicago, USA]
Question: 36
Which of the
following data type
(A) Class
(B) List
(C) Tuple
(D) Dictionary
Show Ans
Ans: D
Forum
Level: Beginner Category: variables
[Posted by: Admin | Chicago, USA]
Question: 37
Show Ans
Ans: D
Forum
Level: Beginner Category: operators
[Posted by: Admin | Chicago, USA]
Question: 38
Which of the
following operators
(A) //
(B) %
(C) /
(D) None of the above
Show Ans
Ans: A
Forum
Level: Beginner Category: operators
[Posted by: Admin | Chicago, USA]
Question: 39
19 % 2 in python
(A) 17
(B) 2
(C) 0
(D) None of these
Show Ans
Ans: D
Forum
Level: Beginner Category: operators
[Posted by: Admin | Chicago, USA]
Question: 40
What is the
associativity of
Show Ans
Ans: B
Forum
Level: Beginner Category: operators
[Posted by: Admin | Chicago, USA]
Question: 41
Which of the
following has more
(A) +
(B) /
(C) -
(D) ()
Show Ans
Ans: D
Forum
Level: Beginner Category: operators
[Posted by: Admin | Chicago, USA]
Question: 42
Is Python case
sensitive?
(A) Yes
(B) No
(C) Depends on Python Version
Show Ans
Ans: A
Forum
Level: Beginner Category: other
[Posted by: Admin | Chicago, USA]
Question: 43
Which of the
following variable is
(A) __str
(B) __str
(C) _str_
(D) None of these
Show Ans
Ans: D
Forum
Level: Beginner Category: variables
[Posted by: Admin | Chicago, USA]
Question: 44
(A) type(name)
(B) print(type(name))
(C) print(name)
(D) type()
Show Ans
Ans: B
Forum
Level: Beginner Category: variables
[Posted by: Mayank Patel | Des Moines, IA]
Question: 45
Show Ans
Ans: C
Forum
Level: Practionar Category: variables
[Posted by: Mayank Patel | Des Moines, IA]
Question: 46
Is Tuple mutable?
(A) Yes
(B) No
Show Ans
Ans: B
Forum
Level: Beginner Category: other
[Posted by: Mayank Patel | Des Moines, IA]
Question: 47
(A) a) 2 3 -4 3
(B) b) 2 3 -3 3.12
(C) c) 2 4 -3 3
(D) d) 2 3 -4 3.12
Show Ans
Ans: B
Forum
Level: Expert Category: other
[Posted by: sandeep kumar yadav | ambala,haryana]
Question: 48
import re
sum = 0
pattern = 'back'
if re.match(pattern,
'backup.txt'):
sum += 1
if re.match(pattern,
'text.back'):
sum += 2
if re.search(pattern,
'backup.txt'):
sum += 4
if re.search(pattern,
'text.back'):
(A) 3
(B) 13
(C) 7
(D) 15
Show Ans
Ans: B
Forum
Level: Beginner Category: regularexpressions
[Posted by: Abhinay Ankur | MMU MULLANA AMBALA INDIA]
Question: 49
Which of the
following print
statements will print
Show Ans
Ans: B
Forum
Level: Beginner Category: other
[Posted by: Abhinay Ankur | MMU MULLANA AMBALA INDIA]
Question: 50
Show Ans
Ans: D
Forum
Level: Expert Category: other
[Posted by: sandeep kumar yadav | MMU MULLANA,AMBALA,HARYANA]
Question: 51
Show Ans
Ans: C
Forum
Level: Expert Category: other
[Posted by: sandeep kumar yadav | MMU MULLANA,AMBALA,HARYANA]
Question: 52
What is an exception
(A) Error
(B) Compile time error
(C) Run time error
(D) None
Show Ans
Ans: C
Forum
Level: Beginner Category: exceptions
[Posted by: Gayatri | Piduguralla]
Question: 53
(A) 4
(B) 3
(C) 5
(D) None
Show Ans
Ans: A
Hint:
The funtional arguments are
Forum
Level: Beginner Category: other
[Posted by: Gayatri | Andrapradesh]
[Contribute Here]