Data Science · Python Which of the following is a correct variable assignment? A x = 5y B 5 = x C x : 5 D x = 5 Correct answer MCQSEXAM Show answer Read explanation
Data Science · Python What does the 'print' function do? A Display output on the screen Correct answer B Perform mathematical calculations C Create a loop D Define a variable MCQSEXAM Show answer Read explanation
Data Science · Python What is the correct way to create a dictionary in Python? A dict = {"key1": "value1", "key2": "value2"} Correct answer B dict = ("key1": "value1", "key2": "value2") C dict = ["key1": "value1", "key2": "value2"] D dict = "key1": "value1", "key2": "value2" MCQSEXAM Show answer Read explanation
Data Science · Python What is the purpose of the "if" statement in Python? A To create a loop B To define a function C To perform conditional execution Correct answer D To print a message MCQSEXAM Show answer Read explanation
Data Science · Python What is the difference between a list and a tuple in Python? A Lists are mutable, while tuples are immutable. Correct answer B Lists are ordered, while tuples are unordered. C Lists can contain any data type, while tuples can only contain numbers. D Lists are faster than tuples. MCQSEXAM Show answer Read explanation
Data Science · Python What is the correct way to import a module named "math" in Python? A import math Correct answer B include math C require math D use math MCQSEXAM Show answer Read explanation
Data Science · Python What is the correct way to define a function in Python? A def function_name(parameters): Correct answer B function function_name(parameters): C function function_name = (parameters) => { D void function_name(parameters) { MCQSEXAM Show answer Read explanation
Data Science · Python Which of the following statements is used to create a list in Python? A list = {1, 2, 3} B list = (1, 2, 3) C list = [1, 2, 3] Correct answer D list = "1, 2, 3" MCQSEXAM Show answer Read explanation
Data Science · Python What is the data type of the variable x in the this code? Python x = 10 A int Correct answer B float C string D boolean MCQSEXAM Show answer Read explanation
Data Science · Python Which of the following is the correct way to print "Hello, world!" in Python? A System.out.println("Hello, world!") B print("Hello, world!") Correct answer C echo("Hello, world!") D cout << "Hello, world!" << endl; MCQSEXAM Show answer Read explanation
Data Science · Python Which module in Python provides support for regular expressions? A re Correct answer B regex C string D pattern MCQSEXAM Show answer Read explanation
Data Science · Python What does the __str__ method do in a Python class? A Convert an object to a string Correct answer B Create a string C Print a string D Define a string variable MCQSEXAM Show answer Read explanation
Data Science · Python Which of the following is a valid way to comment out multiple lines in Python? A /* ... */ B // ... // C # ... # Correct answer D <!-- ... --> MCQSEXAM Show answer Read explanation
Data Science · Python What is the purpose of the super() function in Python? A Call a parent class method Correct answer B Call a child class method C Create an instance of a class D Access global variables MCQSEXAM Show answer Read explanation
Data Science · Python How is exception handling implemented in Python? A try-except block Correct answer B catch-throw block C if-else statement D for-in loop MCQSEXAM Show answer Read explanation
Data Science · Python What does the len() function return in Python? A Length of a string B Length of a list Correct answer C Length of a dictionary D Length of a tuple MCQSEXAM Show answer Read explanation
Data Science · Python In Python, which data structure is used to implement a queue? A List Correct answer B Tuple C Queue D Dictionary MCQSEXAM Show answer Read explanation
Data Science · Python What is the primary purpose of the if __name__ == "__main__": statement in a Python script? A Declare variables B Define functions C Execute code when the script is run directly Correct answer D Include external libraries MCQSEXAM Show answer Read explanation
Data Science · Python Which of the following statements is used for importing a module in Python? A import Correct answer B include C require D from MCQSEXAM Show answer Read explanation
Data Science · Python What is the purpose of the __init__ method in Python? A Initialize a variable B Initialize a class C Initialize an object Correct answer D Initialize a module MCQSEXAM Show answer Read explanation