Self Studies

Computer Science Test - 19

Result Self Studies

Computer Science Test - 19
  • 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

    Directions For Questions

    Radha Shah is a programmer, who has recently been given a task to write a python code to perform the following CSV file operations with the help of two user defined functions/modules:

    a. CSVOpen() : to create a CSV file called BOOKS.CSV in append mode containing information of books – Title, Author, and Price.
    b. CSVRead() : to display the records from the CSV file called BOOKS.CSV where the field title starts with 'R'.

    She has succeeded in writing partial code and has missed out certain statements, so she has left certain queries in comment lines.
    import csv
    def CSVOpen():
    with open('books.csv','______',newline='') as csvf:
    #Statement-1
    cw=______ #Statement-2
    ______ #Statement-3
    cw.writerow(['Rapunzel','Jack',300])
    cw.writerow(['Barbie','Doll',900])
    cw.writerow(['Johnny','Jane',280])
    def CSVRead():

    ...view full instructions

    Fill in the appropriate statement to check the field Title starting with 'R' for Statement 3 in the above program.

    Solution

    Title is the first column of CSV file, so its index would be r [0] [0]. Condition to check the field Title starting with 'R' will be r[0][0] = 'R'.

  • Question 2
    5 / -1

    Directions For Questions

    Radha Shah is a programmer, who has recently been given a task to write a python code to perform the following CSV file operations with the help of two user defined functions/modules:

    a. CSVOpen() : to create a CSV file called BOOKS.CSV in append mode containing information of books – Title, Author, and Price.
    b. CSVRead() : to display the records from the CSV file called BOOKS.CSV where the field title starts with 'R'.

    She has succeeded in writing partial code and has missed out certain statements, so she has left certain queries in comment lines.
    import csv
    def CSVOpen():
    with open('books.csv','______',newline='') as csvf:
    #Statement-1
    cw=______ #Statement-2
    ______ #Statement-3
    cw.writerow(['Rapunzel','Jack',300])
    cw.writerow(['Barbie','Doll',900])
    cw.writerow(['Johnny','Jane',280])
    def CSVRead():

    ...view full instructions

    Which statement will be used to create a CSV writer object in Statement 2?

    Solution

    csv. writer is used to insert data to the CSV file. This class returns a writer object which is responsible for converting the user's data into a delimited string.

    Syntax CSV.writer (CSVfile)

    In statement 2, missing code is CSV. writer (csvf) where, csvf is CSV file.

  • Question 3
    5 / -1

    Directions For Questions

    Radha Shah is a programmer, who has recently been given a task to write a python code to perform the following CSV file operations with the help of two user defined functions/modules:

    a. CSVOpen() : to create a CSV file called BOOKS.CSV in append mode containing information of books – Title, Author, and Price.
    b. CSVRead() : to display the records from the CSV file called BOOKS.CSV where the field title starts with 'R'.

    She has succeeded in writing partial code and has missed out certain statements, so she has left certain queries in comment lines.
    import csv
    def CSVOpen():
    with open('books.csv','______',newline='') as csvf:
    #Statement-1
    cw=______ #Statement-2
    ______ #Statement-3
    cw.writerow(['Rapunzel','Jack',300])
    cw.writerow(['Barbie','Doll',900])
    cw.writerow(['Johnny','Jane',280])
    def CSVRead():

    ...view full instructions

    Which statement will be used to create a CSV writer object in Statement 2?

    Solution

    csv. writer is used to insert data to the CSV file. This class returns a writer object which is responsible for converting the user's data into a delimited string.

    Syntax CSV.writer (CSVfile)

    In statement 2, missing code is CSV. writer (csvf) where, csvf is CSV file.

  • Question 4
    5 / -1

    Which of the following terms are used to protects Intellectual Property?

    Solution

    Intellectual property rights:

    • Intellectual property rights (IPR) refer to the legal rights given to the inventor or creator to protect his invention or creation for a certain period of time. Intellectual Property is legally protected through patents, trademarks, copyrights, trade secrets, etc.​ 

    Copyright:

    • Copyright grants legal rights to creators for their original works like writing, photograph, audio recordings, video, sculptures, architectural works, computer software, and other creative works like literary and artistic work. 

    Patent:

    • A patent is usually granted for inventions. Unlike copyright, the inventor needs to apply (file) for patenting the invention.

    Trademark:

    • A trademark includes any visual symbol, word, name, design, slogan, label, etc., that distinguishes the brand or commercial enterprise, from other brands or commercial enterprises.

    Hence the correct answer is All the above.

  • Question 5
    5 / -1

    When executing the given Python code, which of the following exceptions will occur?

    a = 10

    b = 0

    c = a/b

    print(c)

    Solution

    Concept:

    The given code is,

    a = 10

    b = 0

    c = a/b

    print(c)

    A number must be divided by another number that is not zero. If we write a simple program that divides an integer by zero, the Python interpreter will throw a ZeroDivisionError. This error will occur if the division denominator is set to zero.

    Hence it throws the Zero Division Error.

    Hence the correct answer is Zero Division Error.

  • Question 6
    5 / -1

    Which of the following is not a built-in exceptions in Python?

    Solution

    Concept:

    Built-in exceptions are the exceptions that are available in Python libraries. These exceptions are suitable to explain certain error situations. Some of the commonly occurring built-in exceptions are SyntaxError, ValueError, IOError, KeyboardInterrupt, ImportError, EOFError, ZeroDivisionError, IndexError, NameError, IndentationError, TypeError,and OverFlowerror.

    ZeroDivisionError:
    It is raised when the denominator in a division operation is zero.

    OverFlowError:
    It is raised when the result of a calculation exceeds the maximum limit for the numeric data type.

    KeyboardInterrupt:
    It is raised when the user accidentally hits the Delete or Esc key while executing a program due to which the normal flow of the program is interrupted.

    SyntaxError:
    It is raised when there is an error in the syntax of the Python code.

    ValueError:
    It is raised when a built-in method or operation receives an argument that has the right data type but mismatched or inappropriate values.

    IOError:
    It is raised when the file specified in a program statement cannot be opened.

    ImportError:
    It is raised when the requested module definition is not found.

    EOFError:
    It is raised when the end of the file condition is reached without reading any data by input().

    Hence the correct answer is None of the above.

  • Question 7
    5 / -1

    Consider the following array and what is the status of the array after the fourth pass when we use the insertion sort?

    Array Elements: 20, 16, 12, 8, 4, 1

    Solution

    Concept:
    Insertion sort:
    Insertion sort is a basic sorting algorithm that operates in the same manner that you arrange cards in your hands. The array is divided into two halves, one sorted and one not. Values from the unsorted section are selected and placed in the sorted section at the appropriate location.
    The given array is,
    Input: 20, 16, 12, 8, 4, 1
    Output:1, 4, 8, 12, 16, 20

    Pass 1:
    Consider the key is 16 and move the elements of array index 1 to 0
    swaps are required because 20 is greater than 16.
    Swap the elements 20 and 16
    16, 20, 12, 8, 4, 1
    No swaps are required because till array 1 index is sorted in order.
    16, 20, 12, 8, 4, 1
    Total swaps are = 1

    Pass 2:
    Consider the key is 12 and move the elements of array index 2 to 0
    swaps are required because 20 is greater than 12.
    Swap the elements 20 and 12
    16, 12, 20, 8, 4, 1
    swaps are required because 16 is greater than 12.
    Swap the elements 16 and 12
    12, 16, 20, 8, 4, 1
    No swaps are required because till the array 2 index is sorted in order.
    12, 16, 20, 8, 4, 1
    Total swaps are=3

    Pass 3:
    Consider the key is 8 and move the elements of array index 3 to 0
    swaps are required because 20 is greater than 8.
    Swap the elements 20 and 8
    12, 16, 8, 20, 4, 1
    swaps are required because 16 is greater than 8.
    Swap the elements 16 and 8
    12, 8, 16, 20, 4, 1
    swaps are required because 12 is greater than 8.
    Swap the elements 12 and 8
    8, 12, 16, 20, 4, 1
    No swaps are required because till array 3 index is sorted in order.
    8, 12, 16, 20, 4, 1
    Total swaps are=6

    Pass 4:
    Consider the key is 4 and move the elements of array index 4 to 0
    swaps are required because 20 is greater than 4.
    Swap the elements 20 and 4
    8, 12, 16, 4, 20, 1
    swaps are required because 16 is greater than 4.
    Swap the elements 16 and 4
    8, 12, 4, 16, 20, 1
    swaps are required because 12 is greater than 4.
    Swap the elements 12 and 4
    8, 4, 12, 16, 20, 1
    swaps are required because 8 is greater than 4.
    Swap the elements 8 and 4
    4, 8, 12, 16, 20, 1
    No swaps are required because till array 4 index is sorted in order.
    4, 8, 12, 16, 20, 1
    Total swaps are=10

    Pass 5:
    Consider the key is 1 and move the elements of array index 5 to 0
    swaps are required because 20 is greater than 1.
    Swap the elements 20 and 1
    4, 8, 12, 16, 1, 20
    swaps are required because 16 is greater than 1.
    Swap the elements 16 and 1
    4, 8, 12, 1, 16, 20
    swaps are required because 12 is greater than 1.
    Swap the elements 12 and 1
    4, 8, 1, 12, 16, 20
    swaps are required because 8 is greater than 1.
    Swap the elements 8 and 1
    4, 1, 8, 12, 16, 20
    swaps are required because 4 is greater than 1.
    Swap the elements 4 and 1
    1, 4, 8, 12, 16, 20
    No swaps are required because till array 5 index is sorted in order.
    1, 4, 8, 12, 16, 20
    Total swaps are=15
    The sorted array is
    1, 4, 8, 12, 16, 20
    Hence the correct answer is 4, 8, 12, 16, 20, 1.

  • Question 8
    5 / -1

    Let us consider a list of numbers (34, 16, 2, 93, 80, 77, 51) and has table size is 10. What is the order of elements(from index 0 to size-1) in the hash table?

    Solution

    Concept:

    Hashing:

    Hashing is the process of employing an algorithm to turn any length of input into a fixed-size string or integer. The principle behind hashing is to utilize a hash function to transform a given key to a smaller integer, which is then used as an index in a hash table.
    A simple hash function that works with numeric values is known as the remainder method. It takes an element from a list and divides it by the size of the hash table. The remainder so generated is called the hash value.
    h(element) = element % size(hash table)
    The given data,
    list of numbers (34, 16, 2, 93, 80, 77, 51) and has a table size is 10.

    The hash table is,

    The remaining index stores the null values.

    Hence the correct answer is 80, 51, 2, 93, 34, null, 16, 77, null, null.

  • Question 9
    5 / -1

    The elements 9, 5, 7, and 2 are in the queue and are eliminated one by one. The order of elements received is __________?

    Solution

    Concept:

    Queue:

    • The queue is an abstract data structure, somewhat similar to Stacks.
    • Insertion in a queue happens at the rear end and deletion happens at the front end.
    • Unlike stacks, a queue is open at both ends. One end is always used to insert data (en queue) and the other is used to remove data (de queue). Queue follows the First-In-First-Out methodology, i.e., the data item stored first will be accessed first.
    • Queue follows the principle of First In First Out (FIFO) and Last In Last Out (LILO)

    Queue follows the principle of First In First Out so the element which comes first popped first. The poped elements order is 9, 5, 7, and 2.

    Hence the correct answer is 9, 5, 7, and 2.

  • Question 10
    5 / -1

    Consider the following real-life example.

    If a person uses someone’s song as background music in his/her music video then could be an act a person is an example of:

    Solution

    The correct answer is option 1.

    Concept:

    ​Copyright Infringement:

    The unauthorized use of someone else's copyrighted work is called copyright infringement. As a result, it is the unauthorized use of another person's copyrighted work, infringing on the copyright holder's rights to reproduce, distribute, exhibit, or perform the protected work.

    Consider the following real-life example. 

    If a person uses someone’s song as background music in his/her music video then could be an act a person is an example of copyright infringement. 

    • Copyright infringement occurs when a third party infringes on the copyright holder's rights, such as the exclusive use of a work for a specified period of time.
    • Music and movies are two of the most well-known kinds of entertainment that are subjected to substantial copyright violations. Infringement lawsuits may result in contingent liabilities, or funds set aside in the event of a lawsuit.

    Hence the correct answer is Copyright Infringement.

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