NEW
Font size
WorksheetsPython Basics till Logical Operators
Total questions: 35
Worksheet time: 11mins
Who developed the Python programming language?
James Gosling
Guido van Rossum
Dennis Ritchie
Bjarne Stroustrup
In which year was Python first released?
1995
1989
1991
2000
Why is the language named 'Python'?
It is named after a type of snake.
It was an acronym for "Program Your Tasks on Numbers."
It is a randomly chosen name.
Guido van Rossum was a fan of the television show "Monty Python's Flying Circus."
What was the major feature introduced in Python 2.0?
Object-oriented programming
Garbage collection using reference counting
List comprehensions
Dynamic typing
Which of the following statements is true about Python 3?
It is backward-compatible with Python 2.
It was released in 2008 to address the shortcomings of Python 2.
Python 3.0 introduced the print statement.
Python 3 removed support for object-oriented programming.
Which of the following operators has lower precedence than the comparison operators (e.g., ==, <, >)?
Logical OR (or)
Addition (+)
Bitwise AND (&)
Exponentiation (**)
What is the associativity of the assignment operator = in Python?
Left-to-right
Right-to-left
Non-associative
Undefined
Which operator has the highest precedence in Python?
Multiplication (*)
Parentheses (())
Logical AND (and)
Exponentiation (**)
What is the associativity of the exponentiation operator (**) in Python?
Left-to-right
Right-to-left
Non-associative
Both A and B
Which of the following correctly describes the precedence order of these operators?
*, +, ==, not
not, ==, *, +
*, +, not, ==
+, *, not, ==
Which of these is NOT a Python token?
Keyword
Identifier
Literal
Indentation
Which of the following is a valid floating-point literal?
1.0e-2
0x1.2p3
.5
All of the above
What will happen if you use a keyword as an identifier?
ValueError
SyntaxError
RuntimeError
LogicalError
What is the type of the literal None in Python?
String
Boolean
NoneType
NullType
What is the difference between keywords and identifiers?
Keywords can only be used for variable names, whereas identifiers are reserved words.
Keywords are predefined and reserved, while identifiers are user-defined names.
Both keywords and identifiers can be used interchangeably.
Identifiers are reserved words, whereas keywords are user-defined.
Which of the following is NOT a valid Python keyword?
pass
yield
define
async
Which of these are valid literals in Python?
0b101
"Hello"
3j
All of the above
What will be the output of the following expression?
not (4 > 3 and 7 < 10) or (5 != 5 and 2 < 1)
True
False
None
SyntaxError
What will be the output of the following expression?
not 0 or 1 and 2
True
2
False
0
What will be the result of this expression?
not (6 and 0) or 3 and not 0
True
False
3
1
Evaluate the following:
4 * 2 > 7 and 3 * 2 == 9 or 10 // 3 > 3
True
False
None
SyntaxError
What will be the output of the following code?
print(input("Enter a number: ") + 5)
Displays the entered number plus 5.
Concatenates the entered value with 5.
Error: Unsupported operand types for +.
None of the above.
What is the output of the following code?
print("Value is:", print("Nested print"))
Value is: Nested print\n
Value is: None Nested print\n
Nested print\n
Nested print\nValue is: None\n
According to PEP 8, what is the maximum recommended line length for Python code?
80 characters
120 characters
79 characters
101 characters
Which of the following statements about PEP 20 (The Zen of Python) is incorrect?
It can be accessed by importing this in Python.
It consists of 20 guiding principles for Python's design.
The principle "Readability counts" is a part of PEP 20.
The last principle is written as "There should be one-- and preferably only one --obvious way to do it."
Which of the following Zen of Python principles is NOT explicitly stated in PEP 20?
"Simple is better than complex."
"Beautiful is better than ugly."
"Readability counts."
"Performance matters more than readability."
What is the primary purpose of a flowchart?
To write detailed code for a program
To visually represent the logic of a process or algorithm
To debug code more efficiently
To measure the performance of an algorithm
Which of the following best describes pseudocode?
A high-level description of an algorithm in plain language
A fully functional Python program
A flowchart representation of a program
A machine-readable code for compilers
Which symbol is typically used in a flowchart to represent a decision?
Oval
Rectangle
Diamond
Arrow
What is the output of the following pseudocode?
SET x = 5
SET y = 10
IF x + y > 15 THEN
PRINT "Sum is large"
ELSE
PRINT "Sum is small"
Sum is large
Sum is small
Error in pseudocode
No output
Which of the following is NOT a characteristic of a good algorithm?
Finiteness
Ambiguity
Effectiveness
Definiteness
What does PEP stand for in Python?
Python Execution Protocol
Python Enhancement Proposal
Python Efficiency Practice
Python Extended Principles
What will the following code output?
x = 1.5
y = 2
z = (x + y) * (1 + 1j)
print(type(z))
<class 'int'>
<class 'float'>
<class 'complex'>
Error
What will happen when the following code is executed?
x = int("12.34")
12
12.34
Error: ValueError
Error: TypeError
What will happen when the following code is executed?
x = "hello"
y = 3
print(x * y + y)
hellohellohello3
hellohellohellohello
Error: ValueError
Error: TypeError
