Test Your Python Skills! Hardest Trivia Questions Quiz
Approved & Edited byProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Please select the logo of Python in the given image.
2.
Which is the correct operator for power(x^y)?
A.
X^y
B.
X**y
C.
X^^y
D.
None of the mentioned
Correct Answer A. X^y
Explanation The correct operator for exponentiation is represented by the symbol "^". For example, "x^y" denotes raising the base x to the power of the exponent y, resulting in x multiplied by itself y times. This notation is commonly used in mathematical expressions and programming languages for power operations.
Rate this question:
3.
Which one of these is floor division?
A.
/
B.
//
C.
%
D.
None of the mentioned
Correct Answer B. //
Explanation The double forward slash operator (//) represents floor division. Floor division divides the two numbers and returns the largest integer that is less than or equal to the result. For example, 7 // 2 would result in 3, as it divides 7 by 2 and rounds down to the nearest whole number.
Rate this question:
4.
What is answer of this expression, 22 % 3 is?
A.
7
B.
1
C.
0
D.
5
Correct Answer B. 1
Explanation The expression 22 % 3 calculates the remainder when 22 is divided by 3. In this case, 22 divided by 3 equals 7 with a remainder of 1. Therefore, the answer to the expression is 1.
Rate this question:
5.
You can perform mathematical operation on String?
A.
True
B.
False
Correct Answer B. False
Explanation Mathematical operations cannot be performed directly on strings. Strings are a sequence of characters and do not have inherent mathematical properties. However, some programming languages may allow certain operations on strings, such as concatenation or comparison, but these are not considered mathematical operations.
Rate this question:
6.
Operators with the same precedence are evaluated in which manner?
A.
Left to Right
B.
Right to Left
Correct Answer A. Left to Right
Explanation Operators with the same precedence are evaluated from left to right. This means that when there are multiple operators with the same level of precedence in an expression, the evaluation starts from the leftmost operator and continues towards the right. The operands are evaluated in the order they appear in the expression, and the result is obtained by performing the operations in the order they are encountered.
Rate this question:
7.
What is the output of this expression, 3*1**3?
A.
27
B.
9
C.
3
D.
1
Correct Answer C. 3
Explanation The expression 3*1**3 can be evaluated by following the order of operations, which states that exponentiation should be done before multiplication. Since the exponentiation operator (**) has higher precedence than the multiplication operator (*), the expression can be rewritten as 3 * (1**3). Evaluating 1**3 first, we get 1. Therefore, the output of the expression is 3.
Rate this question:
8.
Which one of the following have the same precedence?
A.
Addition and Subtraction
B.
Multiplication and Division
C.
Both the options
D.
None of the options
Correct Answer C. Both the options
Explanation Both addition and subtraction have the same precedence, meaning they are evaluated from left to right in an expression. Similarly, multiplication and division also have the same precedence and are evaluated from left to right. Therefore, both options have the same precedence.
Rate this question:
9.
Int(x) means variable x is converted to integer.
A.
True
B.
False
Correct Answer A. True
Explanation The statement "Int(x) means variable x is converted to integer" is true. The function "Int()" is commonly used in programming languages to convert a variable or value to an integer data type. This function truncates any decimal places and returns the whole number part of the value. So, if we apply "Int(x)" to a variable x, it will convert x to an integer.
Rate this question:
10.
Which one of the following have the highest precedence in the expression?
A.
Exponential
B.
Addition
C.
Multiplication
D.
Parentheses
Correct Answer D. Parentheses
Explanation Parentheses have the highest precedence in an expression. This means that any operations or calculations within parentheses should be performed first before any other operations. Parentheses help to clarify the order of operations and ensure that the correct calculations are made.
Rate this question:
11.
What is returned by math.ceil(3.4)?
A.
3
B.
4
Correct Answer B. 4
Explanation The math.ceil() function in Python returns the smallest integer greater than or equal to a given number. In this case, the given number is 3.4. Since the smallest integer greater than or equal to 3.4 is 4, the correct answer is 4.
Rate this question:
12.
What is the value returned by math.floor(3.4)?
A.
3
B.
4
Correct Answer A. 3
Explanation The math.floor() function in Python returns the largest integer less than or equal to a given number. In this case, the given number is 3.4. Since 3 is the largest integer that is less than or equal to 3.4, the value returned by math.floor(3.4) is 3.
Rate this question:
13.
What is the value returned by math.fact(6)?
A.
720
B.
6
C.
[6,5,4,3,2,1]
D.
Error
Correct Answer D. Error
Explanation The correct answer is "error" because there is no function called "math.fact" in the standard math library. Therefore, calling "math.fact(6)" would result in an error.
Rate this question:
14.
Which of the following statement prints hello\example\test.txt ?
A.
Print(“hello\example\test.txt”)
B.
Print(“hello\\example\\test.txt”)
C.
Print(“hello\”example\”test.txt”)
D.
Print(“hello”\example”\test.txt”)
Correct Answer B. Print(“hello\\example\\test.txt”)
Explanation The correct answer is print(“hello\\example\\test.txt”). This is because the backslash (\) is an escape character in Python, which is used to indicate special characters. In order to print a backslash itself, we need to use a double backslash (\\). So, the correct statement is the one that uses double backslashes to print the desired string.
Rate this question:
15.
Suppose s is “\t\tWorld\n”, what is s.strip() ?
A.
\t\tWorld\n
B.
\tWorld\n
C.
\t\tWORLD\n
D.
World
Correct Answer D. World
Explanation The strip() method in Python removes leading and trailing whitespace characters from a string. In this case, the string s is "\t\tWorld" which has two leading tab characters. So, s.strip() will remove these tab characters and return the string "World".
Rate this question:
16.
What is the output of “hello”+1+2+3 ?
A.
Hello123
B.
Hello
C.
Error
D.
Hello6
Correct Answer C. Error
Explanation The output of "hello"+1+2+3 would be "hello123" because when a string is concatenated with a number, the number is converted to a string and appended to the original string. Therefore, "hello" is concatenated with "1" to form "hello1", then "hello1" is concatenated with "2" to form "hello12", and finally "hello12" is concatenated with "3" to form "hello123". Hence, the correct answer is "hello123".
Rate this question:
17.
Say s=”hello” what will be the return value of type(s) ?
A.
Int
B.
Bool
C.
Str
D.
String
Correct Answer C. Str
Explanation The return value of type(s) will be "str" because the type() function in Python is used to determine the data type of a variable or value, and in this case, the variable s is a string ("hello"). Therefore, the return value will be "str".
Rate this question:
18.
Python is case sensitive when dealing with identifiers?
A.
True
B.
False
Correct Answer A. True
Explanation Python is case sensitive when dealing with identifiers, meaning that it distinguishes between uppercase and lowercase letters in variable names, function names, and other identifiers. This means that variables named "myVariable" and "myvariable" would be considered as two separate identifiers in Python. Therefore, the answer "True" is correct.
Rate this question:
19.
What is the maximum possible length of an identifier?
A.
31 characters
B.
310 characters
C.
255 characters
D.
None of the mentioned
Correct Answer D. None of the mentioned
Explanation The question asks for the maximum possible length of an identifier, but none of the given options provide the correct answer. The maximum length of an identifier depends on the programming language being used, as different languages have different limitations on identifier length. Therefore, none of the mentioned options is the correct answer.
Rate this question:
20.
Which of the following is invalid?
A.
_a=1
B.
__a = 1
C.
A_a = 1
D.
1 = _a
Correct Answer D. 1 = _a
Explanation The given statement "1 = _a" is invalid because in Python, variable names cannot start with a number. They must start with a letter or an underscore. Therefore, "1 = _a" violates this rule and is not a valid assignment statement.
Rate this question:
21.
Which of the following is an invalid variable?
A.
My_string_1
B.
1st_string
C.
Foo
D.
_a
Correct Answer B. 1st_string
Explanation The variable "1st_string" is invalid because it starts with a number, which is not allowed in variable names. Variable names in most programming languages must start with a letter or an underscore.
Rate this question:
22.
Which of the following cannot be a variable?
A.
__init__
B.
In
C.
It
D.
On
Correct Answer B. In
Explanation The word "in" cannot be a variable because it is a reserved keyword in many programming languages, including Python. Reserved keywords are predefined and have special meanings in the language, so they cannot be used as variable names.
Rate this question:
23.
Which of the following is the use of function in python?
A.
Functions are reusable pieces of programs
B.
Functions don’t provide better modularity for your application
C.
You can’t also create your own functions
D.
All of the mentioned
Correct Answer A. Functions are reusable pieces of programs
Explanation Functions in Python are reusable pieces of programs that allow you to break down complex tasks into smaller, manageable chunks of code. They help improve the modularity and organization of your application by promoting code reusability. With functions, you can define your own custom functions to perform specific tasks, making your code more efficient and easier to maintain. Therefore, the correct answer is "Functions are reusable pieces of programs."
Rate this question:
24.
Which keyword is use for function?
A.
Fun
B.
Def
C.
Function
D.
Define
Correct Answer B. Def
Explanation The keyword "def" is used to define a function in programming languages like Python. It is followed by the name of the function and a set of parentheses, which can include parameters. The "def" keyword is essential in declaring a function and indicating that the following code block is the definition of that function.
Rate this question:
25.
Which of these in not a core datatype?
A.
Lists
B.
Dictionary
C.
Tuples
D.
Class
Correct Answer D. Class
Explanation The question asks for a core datatype that is not included in the given options. The options include Lists, Dictionary, Tuples, and Class. Lists, Dictionary, and Tuples are all core datatypes in programming languages like Python. However, Class is not a core datatype. It is a construct used to create objects and define their behavior and properties. Therefore, Class is the correct answer as it is not a core datatype.
Rate this question:
26.
What is the return type of function id ?
A.
Int
B.
Float
C.
Dict
D.
List
Correct Answer A. Int
Explanation The return type of the function "id" is "int". This means that the function will always return an integer value.
Rate this question:
27.
The value of the expressions 4/(3*(2-1)) and 4/3*(2-1) is the same. State whether true or false.
A.
True
B.
False
Correct Answer A. True
Explanation The expressions 4/(3*(2-1)) and 4/3*(2-1) both involve the same mathematical operations: division, multiplication, and subtraction. According to the order of operations (PEMDAS/BODMAS), parentheses should be evaluated first, followed by multiplication and division from left to right. In both expressions, the parentheses are evaluated first, resulting in 4/(3*1) and 4/3*1, which simplifies to 4/3 and 4/3, respectively. Therefore, the value of both expressions is the same, making the answer "True".
Rate this question:
28.
The result of the expression given A % B // A,
if A= 16 and B = 15 is ________
Correct Answer Zero, zero, 0
Explanation The expression A % B // A can be broken down into two parts: A % B and the result of that divided by A. In this case, A = 16 and B = 15. When we calculate 16 % 15, the remainder is 1. Dividing 1 by 16 gives us 0.0625, but since we are using integer division, the decimal part is truncated and we are left with 0 as the final result. Therefore, the result of the expression is "Zero, zero, 0".
Rate this question:
29.
The value of x is _______ if : x = int(43.55+2/2)
Correct Answer 44
Explanation The value of x is 44 because the expression inside the int() function is evaluated first. The expression 43.55 + 2/2 is equal to 44. The int() function then converts this decimal number to an integer, resulting in the value of x being 44.
Rate this question:
30.
What is the value of the following expression? : 2+4.00, 2**4.0
A.
(6.0, 16.0)
B.
(6.00, 16.00)
C.
(6, 16)
D.
(6.00, 16.0)
Correct Answer A. (6.0, 16.0)
Explanation The expression 2+4.00 evaluates to 6.0 because adding an integer (2) to a float (4.00) results in a float. The expression 2**4.0 evaluates to 16.0 because the double asterisk (**) represents exponentiation, so 2 raised to the power of 4.0 equals 16.0. Therefore, the correct answer is (6.0, 16.0).
Rate this question:
31.
Which of the following functions is a built-in function in python?
A.
SearcMe()
B.
Math
C.
String
D.
Print()
Correct Answer D. Print()
Explanation The correct answer is "print()". This is a built-in function in Python that is used to display output on the console. It is commonly used for debugging purposes or to display information to the user. The other options, "searcMe()", "Math", and "String", are not built-in functions in Python.
Rate this question:
32.
Math.round(4.576) = ________
Correct Answer 5
Explanation The Math.round() function is used to round a number to the nearest integer. In this case, the number 4.576 is rounded to the nearest integer, which is 5. However, since the question asks for the result of Math.round(4.576), the answer is 5. This is because when a decimal number is exactly halfway between two integers, Math.round() rounds to the nearest even integer.
Rate this question:
33.
________ keyword is used to define a function in python
Correct Answer def
Explanation The "def" keyword is used to define a function in Python. It is followed by the name of the function and a pair of parentheses, which may contain parameters for the function. The function definition is then followed by a colon and an indented block of code that represents the body of the function. This block of code is executed whenever the function is called.
Rate this question:
34.
String object in python is
A.
Str
B.
String
C.
Text
D.
STR
Correct Answer A. Str
Explanation In Python, a string object is represented by the keyword "str". This keyword is used to declare and manipulate string variables in the code. It is the standard way to define and work with textual data in Python.
Rate this question:
35.
The ________ function is used in python to get inbuild help.
Correct Answer help, help()
Explanation The "help" function in Python is used to get built-in help. It provides information and documentation about various Python objects such as modules, functions, classes, etc. The "help()" function, on the other hand, is used to invoke the built-in help system. When called without any arguments, it starts an interactive help session where you can enter the name of the object you want help with.
Rate this question:
36.
Which is the invalid datatype in python
A.
Double
B.
Float
C.
Int
D.
List
Correct Answer A. Double
Quiz Review Timeline +
Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.