-
Which symbol is used for comments in Python?
A. //
B. #
C. <!-- -->
D. /* */
Answer: B -
Which data type is immutable?
A. List
B. Dictionary
C. Tuple
D. Set
Answer: C -
What is the output of
type(10)?
A.<class 'str'>
B.<class 'int'>
C.<class 'float'>
D.<class 'list'>
Answer: B -
Which function returns the length of an object?
A. size()
B. count()
C. len()
D. length()
Answer: C -
Which loop is used when the number of iterations is unknown?
A. for
B. while
C. do-while
D. loop
Answer: B -
Which operator performs exponentiation?
A. ^
B. **
C. *
D. //
Answer: B -
What is the output of
3 * 'Hi'?
A. Hi
B. 3Hi
C. HiHiHi
D. Error
Answer: C -
Which module is used for regular expressions?
A. regex
B. reg
C. re
D. expr
Answer: C -
Which statement is used to handle exceptions?
A. try
B. throw
C. error
D. catch
Answer: A -
What is
Nonein Python?
A. Zero
B. Boolean false
C. Absence of value
D. Empty list
Answer: C -
Which is not a valid Python data type?
A. tuple
B. array
C. set
D. list
Answer: B -
Which of these defines a function?
A. function test():
B. def test():
C. fun test():
D. create test():
Answer: B -
Which operator is used for floor division?
A. /
B. //
C. %
D. **
Answer: B -
What does
breakdo?
A. Terminates loop
B. Skips iteration
C. Restarts loop
D. Exits program
Answer: A -
Which method adds an element to a list?
A. add()
B. insert()
C. append()
D. push()
Answer: C -
What does
pop()do in a list?
A. Removes last element
B. Removes first element
C. Removes all elements
D. Adds element
Answer: A -
Which converts a string to an integer?
A. str()
B. float()
C. int()
D. chr()
Answer: C -
Which of the following is unordered?
A. List
B. Tuple
C. Set
D. String
Answer: C -
Python was developed by:
A. Dennis Ritchie
B. Guido van Rossum
C. James Gosling
D. Bjarne Stroustrup
Answer: B -
Which is used to install packages?
A. installpy
B. pkg
C. pip
D. pyinstall
Answer: C -
Which keyword creates a class?
A. class
B. define
C. struct
D. object
Answer: A -
Self in a class refers to:
A. Parent class
B. Current object
C. Module
D. Variable
Answer: B -
Which method is a constructor?
A. start()
B. init()
C. begin()
D. constructor()
Answer: B -
Which keyword is used to inherit a class?
A. using
B. inherit
C. extends
D. class Child(Parent)
Answer: D -
Which of the following is used for documentation?
A. Single quotes
B. Multi-line comment
C. Docstring (""" """)
D. # comment
Answer: C -
Which function is used to get input from user?
A. scanf()
B. read()
C. input()
D. enter()
Answer: C -
What does
strip()do?
A. Removes spaces
B. Removes first character
C. Adds spaces
D. Removes integers
Answer: A -
Which is faster?
A. List
B. Tuple
C. Set
D. Dictionary
Answer: B -
Which library is used for data manipulation?
A. numpy
B. pandas
C. math
D. random
Answer: B -
Which symbol is used for logical AND?
A. &
B. &&
C. and
D. +
Answer: C -
Which of the following is True?
A. Python is case-insensitive
B.SUMandsumare same
C. Python is case-sensitive
D. Variables can start with number
Answer: C -
Which method returns keys of a dictionary?
A. dict.keys()
B. dict.get()
C. dict.items()
D. dict.values()
Answer: A -
Which converts a list to a tuple?
A. set()
B. list()
C. tuple()
D. dict()
Answer: C -
What is
passused for?
A. Exits loop
B. Does nothing
C. Deletes variable
D. Prints message
Answer: B -
Which operator checks identity?
A. ==
B. is
C. equals
D. :=
Answer: B -
Which function gives the max value?
A. high()
B. max()
C. maximum()
D. top()
Answer: B -
Which function returns absolute value?
A. abs()
B. absolute()
C. fabs()
D. val()
Answer: A -
Python supports which programming style?
A. Procedural
B. Object-Oriented
C. Functional
D. All of the above
Answer: D -
Which keyword defines an anonymous function?
A. def
B. lambda
C. fun
D. anon
Answer: B -
What does
continuedo?
A. Ends loop
B. Skips current iteration
C. Stops program
D. Restarts system
Answer: B -
Which is not a keyword?
A. yield
B. async
C. global
D. print
Answer: D -
What does
open()return?
A. List
B. String
C. File object
D. None
Answer: C -
Which method closes a file?
A. stop()
B. close()
C. exit()
D. end()
Answer: B -
Which keyword is used with exceptions?
A. throw
B. expect
C. except
D. error
Answer: C -
What does
isinstance()check?
A. Value equality
B. Type compatibility
C. Memory location
D. Loop iteration
Answer: B -
Which library supports arrays and mathematical operations?
A. pandas
B. numpy
C. random
D. math
Answer: B -
Which retrieves current working directory?
A. os.getcwd()
B. os.getdir()
C. os.path()
D. os.dir()
Answer: A -
Which data type stores key-value pairs?
A. List
B. Tuple
C. Dictionary
D. Set
Answer: C -
Which function converts a value into a string?
A. chr()
B. str()
C. ord()
D. int()
Answer: B -
What is Python's file extension?
A. .pn
B. .pt
C. .py
D. .pyc only
Answer: C
No comments:
Post a Comment