Python Programming - Operators

Exercise : Operators - General Questions
  • Operators - General Questions
16.
Which of the following operators is used to perform floor division?
//
%
/
*
Answer: Option
Explanation:
The // operator performs floor division, which returns the largest integer value that is less than or equal to the result of the division.

17.
What is the output of the following code snippet?
x = "Hello"
y = "World"
z = x + y
print(z)
Hello World
HelloWorld
Hello + World
Error
Answer: Option
Explanation:
The + operator is used to concatenate two strings, which combines the characters of the two strings into a single string.

18.
Which of the following is an example of a comparison operator?
+
or
and
==
Answer: Option
Explanation:

The == operator is a comparison operator in Python, used to check if two values are equal or not.

The other options (+, or, and and) are arithmetic operator, logical operator, and logical operator respectively.


19.
What is the result of the following expression in Python: 7 != '7'?
True
False
None
Error
Answer: Option
Explanation:

The expression 7 != '7' compares the integer value 7 with the string value'7' to check if they are not equal.

In Python, values of different types are considered not equal. Therefore, the result of this expression is True.