NPTEL Programming Data Structure And Algorithms Using Python Assignment 3 Answers 2023

NPTEL Programming Data Structure And Algorithms Using Python Assignment 3 Answers 2023

Are you looking for the Answers to NPTEL Programming Data Structure And Algorithms Using Python Assignment 3? This article will help you with the answer to the National Programme on Technology Enhanced Learning (NPTEL) Course “ Programming Data Structure And Algorithms Using Python Assignment 3

Below you can find the answers for Programming Data Structure And Algorithms Using Python Assignment 3 Answers 2023

NPTEL Programming Data Structure And Algorithms Using Python Assignment 3 Answers 2023:-

Q1. Write three Python functions as specified below. Paste the text for all three functions together into the submission window. Your function will be called automatically with various inputs and should return values as specified. Do not write commands to read any input or print any output.
You may define additional auxiliary functions as needed.
In all cases you may assume that the value passed to the function is of the expected type, so your function does not have to check for malformed inputs.

Define a Python function remdup(l) that takes a nonempty list of integers l and removes all duplicates in l, keeping only the last occurrence of each number. For instance:

Write a Python function splitsum(l) that takes a nonempty list of integers and returns a list [pos,neg], where pos is the sum of squares all the positive numbers in l and neg is the sum of cubes of all the negative numbers in l.

A two dimensional matrix can be represented in Python row-wise, as a list of lists: each inner list represents one row of the matrix. For instance, the matrix



def remdup(l):
    if len(l) <= 1:
    if l[0] in l[1:]:
        return([l[0]] + remdup(l[1:]))


def splitsum(l):
    pos = 0
    neg = 0
    for x in l:
        if x > 0:
            pos = pos + x**2
        if x < 0:
            neg = neg + x**3


def matrixflip(l,d):
  outl = []
  for row in l:
  if d == 'h':
    for row in outl:
  elif d == 'v':


import ast

def tolist(inp):
  inp = "["+inp+"]"
  inp = ast.literal_eval(inp)
  return (inp[0],inp[1])

def parse(inp):
  inp = ast.literal_eval(inp)
  return (inp)

fncall = input()
lparen = fncall.find("(")
rparen = fncall.rfind(")")
fname = fncall[:lparen]
farg = fncall[lparen+1:rparen]

if fname == "remdup":
   arg = parse(farg)
elif fname == "splitsum":
   arg = parse(farg)
elif fname == "matrixflip":
  (arg1,arg2) = parse(farg)
  savearg1 = []
  for row in arg1:
  myans = matrixflip(arg1,arg2)
  if savearg1 == arg1:
    print("Illegal side effect")
   print("Function", fname, "unknown")

Q2. Assume a pandas dataframe df_cars which when printed is as shown below. Based on this information, answer questions 2 and 3.

Of the following set of statements, which of them can be used to extract the column Type as a separate dataframe?

Answer:- a, c

Q3. The method df_cars.describe() will give description of which of the following column?

Answer:- c. Price (in lakhs)

Q4. Which pandas function is used to stack the dataframes vertically?

Answer:- b. pd.concat()

Next Week Answers: Assignment 02

quizxp telegram

Q5. Which of the following are liabraries in Python?

Answer:- d. All of the above

Read the comma-separated values file hotel bookings.csv as a dataframe data hotel and answer questions 6 – 8. Please refer to Hotel Bookings Data Description.pdf for data and variable description.

Q6. Choose the appropriate command(s) to filter those booking details whose reservation-status are a No-show?

Answer:- b, d

If there are any changes in answers will notify you on telegram so you can get 100% score, So Join

Q7. From the same data, find how many bookings were not canceled in the year 2017?

Answer:- a. 9064

Q8. From the total bookings that were made in 2017 and not canceled, which month had the highest number of repeated guests?

Answer:- c. January

Q9. What will be the output of the following code?

Answer:- a. [bool, int, float, float, str]

Q10. Which command is used to generate the plot shown below?

Answer:- a. plt.plot(x, linestyle = “-”)

For other courses answers:- Visit

For Internship and job updates:- Visit

Disclaimer: We do not claim 100% surety of answers, these answers are based on our sole knowledge, and by posting these answers we are just trying to help students, so we urge do your assignment on your own.

if you have any suggestions then comment below or contact us at [email protected]

If you found this article Interesting and helpful, don’t forget to share it with your friends to get this information.