Signup/Sign In

Python Online Practice Test - 13

This Test will cover complete Python with very important questions, starting off from basics to advanced level.
Q. In an interview, following code snippet was provided:
first, second, third = 'red', 'blue', 'green'
first, second, third = second, third, first
complexa, complexb = 1+4j, 4+3j
print(complexa + complexb)
Mark the correct print outputs.
Q. In a competition, following statements were given and Developers were told to mark the False one out of these statements:
Q. A group of developers,were involved in a debate about the features of Java and Python. Following points were raised:

Dev A: The Python interpreter works more at runtime since it finds the type of variables at that time. Since Java is statically typed, this effort is saved. Still, overall Java is slower than Python, as it contains more lines of code. Java should only be used in critical database applications.

Dev B: Java is faster than Python. So in projects, where speed is the issue, we should choose Java. Python is more portable than Java.

Dev C: In critical database applications, Python should be used, as its database access layer, is more stronger than JDBC. Projects where speed is an issue Python should be used, as its code is always smaller than Java.

Mark the correct choice.

Q. A developer was teaching her peer, about negative indices in Python. After explaining the concept, she gave him a test question:
study_program = [23,56,76,89,93]

Choose the correct answer.

Q. A developer was asked to unpack tuple values into some variables. He was confused about doing the same so he consulted his peers. The tuple given was:
tuple_port = ("Pipavav", 1212, "Gujarat")

Mark the correct syntax.

Q. A developer was asked to explain the benefits of using Django for a clients travel web application. He was given a list of following points:
  1. It provides an auto-generated web admin.
  2. Since no pre-packaged API are present, development is easy.
  3. It allows to define a URL for a given function.
  4. It avoids code duplication, by allowing to define a HTML template, for a web page.
  5. It enables separation of business code from HTML.

Mark the correct output of the same.

Q. Given are a few statements regarding migrations in Django:
  1. Commands makemigrations and migrate can run in any order. It does not matter.
  2. makemigrations command, generates, SQL commands to create table based on the classes defined in the file.
  3. Correct command for running makemigrations is - python makemigrations and for migrate is - python migrate.
  4. makemigrations command creates tables of preinstalled apps. migrate command creates table for newly created apps.

Mark if they are True or False.

Q. Consider the following code snippets -
book1 = {'nancy drew',12,1980} 
book1.add('nancy drew')
book2 = {23,34,{'hardy boys'}}
book3 = {['famous five'],56,67}

Mark the correct output of the above.

Q. Consider a few statements regarding Modules and Packages:
  1. The module_name.reload() function allows us to reload the module as required.
  2. Both a module and package, must contain file.
  3. Package is a directory,containing subpackages and modules
  4. When a package is imported, its immediate subpackages and modules, get imported.

Mark them as Correct(C) or Incorrect(In).

Q. Below mentioned, are a few descriptions of the functions present in the Python OS module:
  1. Returns the current working directory of a process.
  2. Creates a hard link that points to a source(src) called dst.
  3. Creates a raw device number, by taking the minor and major device numbers, as arguments.

Map the above with the function name.

Related Tests: