Python Tutorial: CS-Assertion Reason

Monday, 2 September 2024

CS-Assertion Reason

 

ASSERTION& REASON:

(A): Both A and R are true and R is the correct explanation for A.

(B): Both A and R are true and R is not correct explanation for A.

(C): A is true but R is false.

(D): A is false but R is true.

1.       

Assertion(A): List is an immutable data type

Reasoning(R): When an attempt is made to update the value of an immutable variable, the old variable is destroyed and a new variable is created by the same name in memory.

Ans: (A)

2.       

Assertion(A):  Python Standard Library consists of various modules.

Reasoning(R): A function in a module is used to simplify the code and avoids repetition.

Ans: (A)

3.       

Assertion(A) : List can not become key in a dictionary.

Reasoning(R) : Only integers can be keys in a dictionary.

Ans: (B)

4.       

Assertion(A):  To use a function from a particular module, we need to import the module.

Reason (R): import statement can be written anywhere in the program, before using a function from that module.

Ans: (A)

5.       

Assertion(A):  In Python, the "try" block is used to enclose code that might raise an exception.

Reasoning (R): The "try" block is where the program attempts to execute code that might result in an exception. If an exception occurs, it is handled in the corresponding "except" block.

Ans: (A)

6.       

Assertion(A):  The "finally" block in Python is always executed, regardless of whether an exception is raised or not.

Reasoning (R): The "finally" block contains code that is guaranteed to execute, whether an exception occurs within the "try" block or not.

Ans: (B)

7.       

Assertion(A):  Python allows multiple "except" blocks to be used within a single "try" block to handle different exceptions.

Reasoning (R): By using multiple "except" blocks with different exception types, Python provides the flexibility to handle various types of exceptions separately.

Ans: (A)

8.       

Assertion(A):  Using append(), many elements can be added at a time.

Reason(R): For adding more than one element, extend() method can be used.

Ans: (D)

9.       

Assertion(A):  A data structure is a named group of data types.

Reason(R): A data structure has a well-defined operations, behaviour and properties.

Ans: (A)

10.  

Assertion(A):  LIFO is a technique to access data from queues.

Reason(R): LIFO stands for Last In First Out.

Ans: (D)

11.  

Assertion(A):  A Stack is a Linear Data Structure, that stores the elements in FIFO order.

Reason(R): New element is added at one end and element is removed from that end only.

Ans: (D)

12.  

Assertion(A):  An error occurs when one tries to delete an element from an empty stack.

Reason(R): This situation is called an Inspection.

Ans: (C)

13.  

Assertion(A):  A stack is a LIFO structure.

Reason (R): Any new element pushed into the stack always gets positioned at the index after the last existing element in the stack.

Ans: (A)

14.  

Assertion(A):  COUNT function can be work with distinct keyword.

Reason (R): DISTINCT keyword can only be used with COUNT function.

Ans: (B)

15.  

Assertion(A):  HAVING clause can only be used with GROUP BY statement.

Reason (R): WHERE clause can be used in place of HAVING clause in GROUP BY statement.

Ans: (B)

16.  

Assertion(A):  LIKE operator is used for pattern matching in WHERE clause.

Reason (R): % and _ wildcard is used in LIKE operator for making a pattern.

Ans: (A)

17.  

Assertion(A):  The primary key is applied on a column of a table.

Reason (R): NOT NULL constraint restricts NULL values in a column.

Ans: (B)

18.  

Assertion(A):  SUM and COUNT are aggregate functions.

Reason (R): Aggregate functions works on multiple tuples.

Ans: (A)

19.  

Assertion(A):  Primary key constraints allows NULL values.

Reason (R): The primary key constraints ensures that a column can contain unique Values for each row.

Ans: (D)

20.  

Assertion(A):  Unique key constraint allows NULL values.

Reason (R): The unique key constraints ensures that a column can contain unique Values.

Ans: (A)

21.  

Assertion(A):  The HAVING clause is used to filter aggregated data in SQL queries.

Reason (R): The HAVING clause is used to group rows with similar values in one or more column into result sets.

Ans: (A)

22.  

Assertion(A):  Inner Join retrieves rows that have matching values in both tables being joined.

Reason (R): Inner join excludes row with no matching values.

Ans: (A)

23.  

Assertion(A):  Between operator is used to filter data within a specified range.

Reason (R): Where clause works exactly same as between operator

Ans: (B)

24.  

Assertion(A):  The key concept of data structure is to manage the storage of data in the memory efficiently.

Reason (R): The data structure is a way to create a logical structure in the memory so that the storage of numerous data values could be managed using minimum space. It helps in a fast accessing of data during execution of a program.

Ans: (A)

25.  

Assertion(A): Every open file maintains a file-pointer and keeps track of its position after every operation.

Reason (R): Every read and write operation takes place at the current position of the file pointer.

Ans: (B)

26.  

Assertion: The order of execution of the statements in a program is known as flow of control.

Reason: The flow of control can be implemented using control structures.

Ans: (A)

27.  

Assertion: Keyword arguments are related to the function calls.

Reason: When you use keyword arguments in a function call, the caller identifies the arguments by the parameter name.

Ans: (A)

28.  

Assertion(A): - The number of actual parameters in a function call may not be equal to the number of formal parameters of the function.

Reasoning (R):- During a function call, it is optional to pass the values to default parameters.

Ans: (A)

29.  

Assertion(A):  A tuple can be concatenated to a list, but a list cannot be concatenated to a tuple.

Reason (R): Lists are mutable and tuples are immutable in Python.

Ans: (A)

30.  

Assertion(A): - During a function call, the argument list first contains default argument(s) followed by positional argument(s).

Reasoning (R):- Inside a function, we can declare local as well as global arguments.

Ans: (C)

31.  

Assertion(A):  CSV (Comma Separated Values) is a file format for data storage which looks like a text file.

Reason (R): CSV file can be opened and edited in text editor as well as Microsoft excel which has column and row structure.

Ans: (A)

32.  

Assertion(A):  Local Variables are accessible only within a function or block in which it is declared

Reason (R): Global variables are accessible in the whole program.    1

Ans: (B)

33.  

Assertion(A):  Parameters with default arguments can be followed by parameters with no default argument.

Reason (R): Syntactically, it would be impossible for the interpreter to decide which values match which arguments if mixed modes were allowed while providing default arguments.

Ans:

34.  

Assertion(A): - The default arguments can be skipped in the function call.

Reasoning (R):- The function argument will take the default values even if the values are supplied in the function call

Ans:  (A)

35.  

Assertion(A): - If a text file already containing some text is opened in write mode the previous contents are overwritten.

Reasoning (R):- When a file is opened in write mode the file pointer is present at the beginning position of the file

Ans: (A)/ (B)

36.  

str1= “Class” + “Work”

Assertion: Value of str1 will be “ClassWork”.

Reasoning: Operator ‘+’ adds the operands, if both are numbers & concatenates the string if both operands are strings.

Ans: (A)

37.  

Assertion: CSV (Comma Separated Values) is a file format for data storage which looks like a text file.

Reason (R): The information is organized with one record on each line and each field is separated by semi-colon.

Ans: (B)

38.  

Assertion: The default value of an argument will be used inside a function if we do not pass a value to that argument at the time of the function call.

Reason: the default arguments are optional during the function call. It overrides the default value if we provide a value to the default arguments during function calls.

Ans: (A)

39.  

Assertion: Pickling is the process by which a Python object is converted to a byte stream. Reason: load() method is used to write the objects in a binary file. dump() method is used to read data from a binary file.

40.  

Assertion(A):  A binary file stores the data in the same way as stored in the memory.

Reason (R): Binary file in python does not have line delimiter.

Ans: (A)

41.  

Assertion(A): - If the arguments in a function call statement match the number and order of arguments as defined in the function definition, such arguments are called positional arguments.

Reasoning (R):- During a function call, the argument list first contains default argument(s) followed by positional argument(s).

Ans: (B)

 


No comments:

Post a Comment