1.
Which of the following statements is true?
Correct Answer
D. All of the above
Explanation
Python is a high-level programming language, an interpreted language, and an object-oriented language. Python is designed to be easy to read and write, making it a high-level language. It is also interpreted, meaning that it does not need to be compiled before running. Additionally, Python supports object-oriented programming, allowing for the creation and manipulation of objects and classes. Therefore, all three statements are true.
2.
What is used to define a block of code (body of loop, function etc.) in Python?
Correct Answer
C. Indentation
Explanation
In Python, a block of code is defined using indentation. This means that instead of using curly braces or parentheses like in other programming languages, Python uses the indentation level to determine the beginning and end of a block of code. This makes the code more readable and forces the programmer to write clean and well-structured code.
3.
Which of the following is correct?
Correct Answer
D. All of the above
Explanation
The given statement states that all of the options mentioned are correct. The first statement mentions that comments are for programmers to better understand the program, which is true as comments are used to explain the code and make it more readable. The second statement states that the Python Interpreter ignores comments, which is also true as comments are not executed by the interpreter. The third statement mentions that multi-line comments can be written in Python using triple quotes, which is again correct as triple quotes can be used to write comments that span multiple lines. Therefore, all of the options mentioned are correct.
4.
Which of the following is correct?
Correct Answer
A. Variable names can start with an underscore, and keywords cannot be used as a variable name.
Explanation
Variable names in programming languages can start with an underscore. This is a common convention used to indicate that the variable is intended for internal or private use within a program. However, it is important to note that starting a variable name with an underscore does not have any special meaning or functionality in most programming languages.
5.
In the following code, n is a/an _______?
n = '5'
Correct Answer
B. String
Explanation
The variable "n" in the given code is assigned the value '5', which is enclosed in single quotes. In Python, when a value is enclosed in quotes (either single or double), it represents a string. Therefore, the correct answer is string.
6.
What is the output of the following code?
print(1, 2, 3, 4, sep='*')
Correct Answer
C. 1*2*3*4
Explanation
The code uses the print() function to output the numbers 1, 2, 3, and 4 separated by asterisks. The sep parameter is set to '*' which means that the asterisk character will be used as the separator between the numbers. Therefore, the output will be "1*2*3*4".
7.
What is used to take input from the user in Python?
Correct Answer
C. Input()
Explanation
The correct answer is "input()". In Python, the "input()" function is used to take input from the user. It prompts the user to enter a value and returns the entered value as a string. This allows the program to interact with the user and receive input that can be used for further processing or calculations.
8.
What is the output of the following code?
numbers = [2, 3, 4]
print(numbers)
Correct Answer
C. [2, 3, 4]
Explanation
The code declares a list called "numbers" with the values 2, 3, and 4. Then, it prints the list "numbers". Therefore, the output of the code is [2, 3, 4].
9.
What is the output of the following code?
print(3 >= 3)
Correct Answer
B. True
Explanation
The code is checking if 3 is greater than or equal to 3 using the greater than or equal to operator (>=). Since 3 is equal to 3, the expression evaluates to True. Therefore, the output of the code is True.
10.
The statement using and operator results true if _______
Correct Answer
A. Both operands are true
Explanation
The statement using the "and" operator results in true if both operands are true. This means that for the statement to be true, both the first and second operands must be true. If either one or both of the operands are false, the statement will be false.