29 Python (Computer Science) questions asked in DSSSB TGT / PGT previous year papers, each with the correct answer and explanation. Read them free on UTpaper, or attempt the full papers as timed online tests.
Dictionary keys must be unique. The second 10 overwrites the first value but keeps the key's original position, giving {10: 'Decimal', 100: 'Hundred'}.
Which string method, out of the following will always break the string into 3 parts in Python?
ABreak
BPartition
CMid
DSplit
Show answerHide answer
Correct answer: (B) Partition
Explanation
str.partition(sep) always returns a 3-tuple: the part before the separator, the separator, and the part after it. split() can return any number of parts.
Which of the following is false about global variables in Python?
AGlobal immutable variables require global keyword inside function.
BGlobal mutable variables do not require global keyword inside function.
CGlobal keyword is a must for the first time of assignment of a global variable.
DGlobal variables can be accessed any where in the program.
Show answerHide answer
Correct answer: (C) Global keyword is a must for the first time of assignment of a global variable.
Explanation
A variable assigned at the top level of a module is already global, so no global keyword is needed for that first assignment. The keyword is needed only when a function wants to rebind a global name.
Python is case sensitive (Name and name are different variables), so "case insensitive" is not one of its features. It is high-level, interpreted and portable.
Which statement(s) is/are NOT true about the variables in Python Language:
I. Values of every variable can be changed once a variable has been created and assigned value.
II. Assignment statement is used to create a new variable and assign value.
AOnly I
BOnly II
CBoth I and II
DNeither I nor II
Show answerHide answer
Correct answer: (A) Only I
Explanation
Statement II is true: assignment creates a variable and binds a value. Statement I is treated as not true because a variable can only be rebound; values of immutable objects such as strings and tuples cannot be changed in place.
Which of the following is NOT a Data MINING Language?
AR. Language
BWeka
CPython
DBASIC
Show answerHide answer
Correct answer: (D) BASIC
Explanation
R, Python and Weka are widely used for data mining. BASIC is an old general-purpose language, not a data mining tool.
Q19DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 3
Which of the following combination(s) is/are correct?
I. Informative literature – Dictionary
II. Creative or imaginative literature – Novels
AOnly I
BOnly II
CBoth I and II
DNeither I nor II
Show answerHide answer
Correct answer: (C) Both I and II
Explanation
Dictionaries are informative literature, and novels are creative or imaginative literature. Both pairs are correct.
Q20DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 1
Which of the following acts as an intermediary between the specialist and the expert system?
AKnowledge base
BInference engine
CData dictionary
DKnowledge engineer
Show answerHide answer
Correct answer: (D) Knowledge engineer
Explanation
A knowledge engineer extracts knowledge from the human expert (specialist) and encodes it into the expert system's knowledge base, acting as the intermediary between them.
Which of the following type of function used with strings in the Python language
returns the character with the highest ASCII value?
Alen ( )
Bhvalue ( )
Cmax ( )
Dlong ( )
Show answerHide answer
Correct answer: (C) max ( )
Explanation
max() on a string returns the character with the highest ASCII/Unicode value, e.g. max("apple") gives "p". len() gives length; hvalue() and long() are not string functions.
If you encounter an import Error, what does it mean?
I. Python could find pandas in list of available libraries
II. Pandas couldn’t find python in list of available libraries
III. Python couldn’t find Pandas in list of available libraries
AOnly III
BI, II and III
COnly I
DOnly I and III
Show answerHide answer
Correct answer: (A) Only III
Explanation
An ImportError (here ModuleNotFoundError) means Python could not find the pandas module among installed libraries, so only III is correct.
Which of the following is correct for Identifiers name used in Python language?
AAn identifier can have underscore (_) symbol
BWe must use keywords as identifier
CThhere is restriction the length of an identifier
DAn identifier must start with a digit
Show answerHide answer
Correct answer: (A) An identifier can have underscore (_) symbol
Explanation
Python identifiers may contain letters, digits and underscores, so _ is allowed. They cannot start with a digit, cannot be keywords, and have no length limit.
Which symbol is used to add the comment in the code or program to make it more
readable and understandable in Python programming language?
A#
B*
C–
D:
Show answerHide answer
Correct answer: (A) #
Explanation
Python uses # for comments, which make code more readable and are ignored by the interpreter.
How to use these DSSSB TGT / PGT Computer Science questions
Every question here was asked in a real DSSSB TGT / PGT paper; the paper and shift are shown on the card, and the number opens the question on its own page. Try each one before tapping Show answer, then attempt the full DSSSB TGT / PGT papers as timed tests to check your speed under exam conditions.