Self Studies

Computer Science Test - 20

Result Self Studies

Computer Science Test - 20
  • Score

    -

    out of -
  • Rank

    -

    out of -
TIME Taken - -
Self Studies

SHARING IS CARING

If our Website helped you a little, then kindly spread our voice using Social Networks. Spread our word to your readers, friends, teachers, students & all those close ones who deserve to know what you know now.

Self Studies Self Studies
Weekly Quiz Competition
  • Question 1
    5 / -1

    Two statements are given below:

    Statement I: A primary key in DBMS is a field that uniquely identifies each record in a table and can be Null.

    Statement II: A foreign key in DBMS is a field that contains unique values and is used to link related tables together.

    Solution

    A primary key is a field or set of fields in a table that uniquely identifies each record in the table and cannot be Null. It is used to enforce data integrity and to ensure that there are no duplicate records in the table. A foreign key is a field in one table that refers to the primary key in another table. It is used to establish a relationship between two tables, and it ensures that data in one table is linked to data in another table.

  • Question 2
    5 / -1

    The postfix form of A*B + C/D is

    Solution

    Key Points

    The postfix (also known as Reverse Polish Notation - RPN) is a way of writing expressions without the need for parenthesis. It places operators after their operands. To convert the infix expression (A*B + C/D) to postfix, we follow the operands and operators in their order of operation, considering the precedence of operators.

    Given infix expression: (A*B + C/D)

    • Multiply A and B ((A*B))
    • Divide C by D ((C/D))
    • Add the results of steps 1 and 2

    Following these steps in postfix notation:

    • Multiplication of A and B is represented as (AB*)
    • Division of C by D is represented as (CD/)
    • Addition of the results of the above operations is represented by appending a plus (+) symbol after them.

    Therefore, putting it all together, the postfix expression becomes: (AB*CD/+)

    So, the correct option is: AB*CD/+

  • Question 3
    5 / -1

    The file offset position of a file opened in < r > mode is _________.

    Solution

    The correct answer is Begining of the file

    • File offset position: It's the point within a file where the next read or write operation will occur.
    • < r > mode: This mode is designed specifically for reading from a file.

    When you open a file in < r > mode, the file offset position is automatically set to the beginning of the file. This means that any subsequent read operations will start from the first byte of the file.

    Key Points

    • The file offset position can be changed using functions like fseek (in C) or seek (in Python), but it's initially at the beginning in < r > mode.
    • Other file opening modes have different default offset positions:
      • < w > mode (write): Sets the offset to the beginning, overwriting existing content.
      • < a > mode (append): Sets the offset to the end, appending new content.
      • < r+ > mode (read and write): Sets the offset to the beginning, but allows both reading and writing.
  • Question 4
    5 / -1

    Consider the following python code: def myDiv(x, y): if

    y = = 0:

    raise ZeroDivisionError

    return x/y

    What is the output of the following?

    n = myDiv(4,0)

    print(n)

    Solution

    The correct answer is ZeroDivisionError

    1. Function Definition:

    • The code defines a function named myDiv(x, y) that attempts to divide x by y.
    • It checks for a potential division by zero:
      • If y is equal to 0, it raises a ZeroDivisionError to prevent an invalid operation.
      • If y is not 0, it proceeds with the division and returns the result (x/y).

    2. Function Call:

    • The code calls the myDiv function with arguments 4 and 0: n = myDiv(4, 0).
    • Within the function:
      • The check y == 0 evaluates to True, because y is indeed 0.
      • This triggers the raise ZeroDivisionError statement.
      • The function execution stops immediately, and the ZeroDivisionError is raised.

    3. Error Handling:

    • The code doesn't have any explicit error handling mechanisms like try-except blocks.
    • Therefore, the raised ZeroDivisionError propagates up and terminates the program.
    • The print statement print(n) never gets executed.

    Output:

    • The output you'll see is the error message:
    • ZeroDivisionError

    Key Points

    • Python, like most programming languages, doesn't allow division by zero.
    • It raises a ZeroDivisionError to prevent mathematical errors and potential program crashes.
    • It's essential to handle potential errors gracefully with exception handling blocks to ensure program robustness.
  • Question 5
    5 / -1

    _________ Communication mode allows communication in both directions simultaneously.

    Solution

    The correct answer is Full duplex

    Key Points

    The Transmission mode is divided into three categories:

    • Simplex mode
      • In Simplex mode, the communication is unidirectional, i.e., the data flow in one direction. The radio station is an example of simplex channel
    • Half-duplex mode
      • In a Half-duplex channel, direction can be reversed, i.e., the station can transmit and receive the data as well but only one direction at a time. A Walkie-talkie is an example of the Half-duplex mode.
    • Full-duplex mode
      • In Full duplex mode, the communication is bi-directional, i.e., the data flow in both the directions. Example of the full-duplex mode is a telephone network.
  • Question 6
    5 / -1

    Choose the advantages of a database over file system from the following statements.

    A. Reduces data redundancy and saves storage.

    B. Sharing of data is possible.

    C. Difficult to access the data in formatted way.

    D. Data inconsistency is reduced to larger extent

    E. Databases are not portable.

    Choose the correct answer from the options given below:

    Solution

    Key Points

    • A. Reduces data redundancy and saves storage:
      • This is an advantage of databases. By storing data in a centralized location and enforcing data integrity, databases eliminate the need for duplicate copies of data across different files.
    • B. Sharing of data is possible:
      • Databases are designed for multi-user access. They provide mechanisms for controlled sharing of data among authorized users.
    • C. Difficult to access the data in formatted way:
      • This is not necessarily true. Databases offer structured query languages (SQL) for easy and efficient access to data in a formatted way.
    • D. Data inconsistency is reduced to a larger extent:
      • Databases enforce data integrity through constraints and data types, minimizing inconsistencies that can arise with file systems.
    • E. Databases are not portable:
      • Modern databases offer portability features, allowing them to be transferred across different platforms with minimal configuration changes.

    Therefore, options A, B, and D represent the key advantages of databases over file systems.

  • Question 7
    5 / -1

    What is mean by stable sorting algorithm?

    Solution

    Concept

    The stability of a sorting algorithm is concerned with how the algorithm treats equal (or repeated) elements.

    A sorting algorithm is said to be stable if two objects with equal keys appear in the same order in sorted output as they appear in the input array to be sorted.

    Some sorting algorithms are stable by nature like Insertion sort, Merge Sort, Bubble Sort, etc. And some sorting algorithms are not, like Heap Sort, Quick Sort, etc.

  • Question 8
    5 / -1

    What is the return type of readline() function?

    Solution

    CONCEPT:

    In Python we use readline() and readlines() method to read the content of a file.

    readline() method reads a line from the file and return it in the form of the string. It can take a parameter that specifies the maximum number of bytes that can be read from the file. But it cannot read more than one line from the file.

    Syntax: file.readline()

    Return Value: Returns the next line of the file including the newline character.

    readlines() method will append all the lines of a file in the format of a list where each element of the list is a line of the file.

    Syntax: file.readlines()

    Return Value: A list containing the lines.

    To check the type of a return value we can use type() function in python.

    Example: Let us open a file named "data.txt" using open function as follows

    file = open("data.txt", "r")

    lines = file.readlines()

    // using readlines() method to read lines of the data.txt file and store it in lines

    print(type(lines))

    // this will print the type of data stored in lines

  • Question 9
    5 / -1

    In Python code, on encountering a syntax error, the _____________ does not execute the program.

    Solution

    Concept:

    Python is a programming language that is commonly used to create websites and applications, automate operations, and do data analysis. Python is a general-purpose programming language, which means it can be used to develop a wide range of applications and isn't tailored to any particular issue.

    • The interpreter parses our Python code before converting it to Python byte code, which it then executes.
    • During this initial step of program execution, also known as parsing, the interpreter will look for any incorrect syntax in Python.
    • If the interpreter fails to parse our Python code, we have used improper syntax somewhere. The interpreter will try to show us where we made the mistake.
    • In Python code, on encountering a syntax error, the Interpreter does not execute the program.

    Hence the correct answer is Interpreter.

  • Question 10
    5 / -1

    Which mode will write data to a file even if the file does not exist?

    Solution

    CONCEPT:

    To read or write a file, we first need to open it using the open() function, which returns a file object.

    Syntax:

    open(file, mode)

    The "mode" attribute is passed to specify the mode in which we require the file to be opened.

    There are several access modes available for the open() function:

    w+ Opens the file in writing and reading mode or creates the file if it doesn't exist and opens it in write mode

    r+ Opens the file in reading and writing mode but does not create the file if it does not exist.

    a+ Opens the file in append and reading mode or creates the file if it doesn't exist and opens it in append mode.

    Therefore "Both w+ and a+" mode can be used to write data to a file even if the file does not exist.

Self Studies
User
Question Analysis
  • Correct -

  • Wrong -

  • Skipped -

My Perfomance
  • Score

    -

    out of -
  • Rank

    -

    out of -
Re-Attempt Weekly Quiz Competition
Self Studies Get latest Exam Updates
& Study Material Alerts!
No, Thanks
Self Studies
Click on Allow to receive notifications
Allow Notification
Self Studies
Self Studies Self Studies
To enable notifications follow this 2 steps:
  • First Click on Secure Icon Self Studies
  • Second click on the toggle icon
Allow Notification
Get latest Exam Updates & FREE Study Material Alerts!
Self Studies ×
Open Now