Data Science · Python What is the purpose of the 'break' statement in Python? A It skips the current loop iteration B It terminates the loop and resumes execution after the loop Correct answer C It is used to define a new variable D It raises an exception MCQSEXAM Show answer Read explanation
Data Science · Python Which of the following is NOT a valid comparison operator in Python? A = Correct answer B == C != D <> MCQSEXAM Show answer Read explanation
Data Science · Python What does the 'assert' statement in Python do? A It raises an exception if a condition is true Correct answer B It prints a message to the console C It terminates the program D It is used to define a new variable MCQSEXAM Show answer Read explanation
Data Science · Python Which statement is used to raise an exception in Python? A error B raise Correct answer C except D assert MCQSEXAM Show answer Read explanation
Data Science · Python What is the purpose of the 'pass' statement in Python? A It terminates the current loop iteration B It is used to skip code execution C It indicates the end of a function D It defines an empty code block Correct answer MCQSEXAM Show answer Read explanation
Data Science · Python What does the 'finally' block in a 'try-except' statement do? A It defines an alternative condition B It is executed if no exceptions occur C It is always executed, regardless of whether an exception occurs Correct answer D It is used to terminate the program MCQSEXAM Show answer Read explanation
Data Science · Python Which of the following statements is used to handle exceptions in Python? A try B except C catch D both 'try' and 'except' Correct answer MCQSEXAM Show answer Read explanation
Data Science · Python What is the purpose of the 'range' function in Python? A To generate a random number B To create a sequence of numbers Correct answer C To calculate the length of a list D To round a floating-point number MCQSEXAM Show answer Read explanation
Data Science · Python Which of the following statements is true about nested loops in Python? A They are not allowed in Python B They are used to define recursive functions C They are loops within other loops Correct answer D They can only contain 'for' loops MCQSEXAM Show answer Read explanation
Data Science · Python What does the 'else' statement in a loop signify in Python? A It is executed if the loop encounters an error B It indicates the end of the loop C It is executed if the loop completes without encountering a 'break' statement Correct answer D It defines an alternative condition for the loop MCQSEXAM Show answer Read explanation
Data Science · Python Which statement is used to terminate the current loop iteration in Python? A break B continue Correct answer C return D pass MCQSEXAM Show answer Read explanation
Data Science · Python What is the key feature of the 'for' loop in Python? A It requires a condition to terminate B It is used exclusively for numerical iterations C It iterates over a sequence of elements Correct answer D It can only be nested within a 'while' loop MCQSEXAM Show answer Read explanation
Data Science · Python Which of the following statements is used to execute a block of code repeatedly in Python? A if B else C for D while Correct answer MCQSEXAM Show answer Read explanation
Data Science · Python What is the purpose of the 'if' statement in Python program flow? A To create loops B To define functions C To handle conditions and make decisions Correct answer D To import external libraries MCQSEXAM Show answer Read explanation
Data Science · Python What is the purpose of the 'return' statement in a function? A Print a value to the console B Terminate the function executio C Provide a value as the output of the function Correct answer D Define a new variable MCQSEXAM Show answer Read explanation
Data Science · Python Which of the following is a valid way to define a function in Python? A def function_name: B function function_name(): C define function_name(): D def function_name(): Correct answer MCQSEXAM Show answer Read explanation
Data Science · Python What is the purpose of the 'elif' statement? A To terminate the program B To handle multiple conditions after an 'if' statement Correct answer C To define a function D To repeat a block of code MCQSEXAM Show answer Read explanation
Data Science · Python How do you open a file in Python? A open_file("file.txt") B file.open("file.txt") C with open("file.txt", 'r') as f: Correct answer D read_file("file.txt") 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 handle conditions and make decisions Correct answer D To import external libraries MCQSEXAM Show answer Read explanation
Data Science · Python What does the 'len' function do? A Return the length of a list or string Correct answer B Calculate logarithm C Create a new variable D Convert a value to lowercase MCQSEXAM Show answer Read explanation
Data Science · Python What is the result of the expression 3 + 2 * 4? A 20 B 15 C 11 Correct answer D 14 MCQSEXAM Show answer Read explanation
Data Science · Python Which data type is used to store a sequence of characters? A int B float C str Correct answer D list MCQSEXAM Show answer Read explanation
Data Science · Python What is the purpose of the 'input' function? A Display information on the console B Take user input from the console Correct answer C Perform complex calculations D Print the program output MCQSEXAM Show answer Read explanation
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