Nucleus Previous Years Solved Sample Placement Papers
-
Which of the following is the correct extension of the Python file?
A. .python
B. .pl
C. .py Answer: Option C
D. .p
- Solution: ‘.py’ is the correct extension of the Python file. Python programs can be written in any text editor. To save these programs, we need to use the file extension ‘.py’.
-
Is Python code compiled or interpreted?
A. Python code is both compiled and interpreted Answer: Option A
B. Python code is neither compiled nor interpreted
C. Python code is only compiled
D. Python code is only interpreted
- Solution: Python code is first compiled into bytecode and then interpreted by the Python virtual machine, making it both compiled and interpreted.
-
All keywords in Python are in _________.
A. Capitalized
B. lower case
C. UPPER CASE
D. None of the mentioned Answer: Option D
- Solution: Keywords like True, False, and None are capitalized, while the others are in lowercase.
-
What will be the value of the following Python expression?
4 + 3 % 5
A. 7 Answer: Option A
B. 2
C. 4
D. 1
- Solution: The order of precedence is %, +. Hence the expression above simplifies to 4 + 3 = 7.
-
Which of the following is used to define a block of code in Python language?
A. Indentation Answer: Option A
B. Key
C. Brackets
D. All of the mentioned
- Solution: Python uses indentation (whitespace) at the beginning of a line to define a block of code.
-
Which keyword is used for function in Python language?
A. Function
B. def Answer: Option B
C. Fun
D. Define
- Solution: The def keyword is used to create or define a function in Python.
-
Which of the following character is used to give single-line comments in Python?
A. //
B. # Answer: Option B
C. !
D. /*
- Solution: Single-line comments in Python use the hash symbol (#) at the beginning of the line.
-
What will be the output of the following Python code?
i = 1 while True: if i%3 == 0: break print(i) i + = 1
A. 1 2 3
B. error Answer: Option B
C. 1 2
D. None of the mentioned
- Solution: SyntaxError occurs because there shouldn't be a space between "+" and "=" in "+=".
-
Which of the following functions can help us to find the version of Python that we are currently working on?
A. sys.version(1)
B. sys.version(0)
C. sys.version()
D. sys.version Answer: Option D
- Solution: The sys.version provides information about the Python version, build number, compiler, and more.
-
Python supports the creation of anonymous functions at runtime, using a construct called __________.
A. pi
B. anonymous
C. lambda Answer: Option C
D. None of the mentioned
- Solution: Python allows the creation of anonymous functions using the lambda keyword, which is restricted to a single expression.
-
What is the order of precedence in Python?
A. Exponential, Parentheses, Multiplication, Division, Addition, Subtraction
B. Exponential, Parentheses, Division, Multiplication, Addition, Subtraction
C. Parentheses, Exponential, Multiplication, Addition, Division, Subtraction
D. Parentheses, Exponential, Multiplication, Division, Addition, Subtraction Answer: Option D
- Solution: Python follows the PEMDAS (Parentheses, Exponents, Multiplication/Division, Addition/Subtraction) rule for precedence.
-
What will be the output of the following Python code snippet if x = 1?
x << 2
A. 4 Answer: Option A
B. 2
C. 1
D. 8
- Solution: The bitwise left shift of x (1) by 2 positions gives the binary value 0100, equivalent to the decimal value 4.
-
What does pip stand for in Python?
A. Pip Installs Python
B. Pip Installs Packages
C. Preferred Installer Program Answer: Option C
D. All of the mentioned
- Solution: pip is a package manager in Python, known as the Preferred Installer Program, used to install and manage Python packages.