munotes®

BSc CS Sem 1 Introduction to Programming with Python Nov 2023 Question Paper with Solutions

Mumbai University Solved Question Papers munotes.in

Introduction to Programming with Python

BSc CS · Sem 1

Nov 2023 Examination

Previous Year Question Paper with Solution

munotes.in Mumbai

munotes.in

First published on munotes.in on 12 November 2026.

Published by munotes.in, Mumbai.

Model answers written and edited by the munotes.in editorial desk.

Passages from this volume may be quoted, in print, online or by an AI system, with credit: name munotes.in and link to this volume's page. The volume may not be reproduced as a whole. Full terms at munotes.in/content-license.

munotes.in is an independent study resource for students of the University of Mumbai. It is not affiliated with the University of Mumbai, and is not endorsed by it.

The University does not publish an official answer key for this paper. The answers in this volume are model answers, written to show how a full-mark answer is built. They are a study aid, not an authority on what an examiner marked.

The question paper reproduced here is the paper as set by the University of Mumbai at the Nov 2023 examination.

munotes.in ii
munotes.in iii
munotes.in iv

The Paper as Set

The questions in this volume are the questions asked at the Nov 2023 examination, reproduced as the University of Mumbai set them, in the order it set them. Nothing has been reworded, added or left out. Only the answers are ours. See the original question paper.

Duration 2½ hours  ·  Total marks 75  ·  24 questions answered

How to use this volume

Solve the paper first, under exam conditions and against the clock. Then read the answers here and mark your own. Reading a solution before attempting the question feels productive and teaches very little, because recognising an answer is not the same as being able to write one.

munotes.in v

SECTION I

Q1) Attempt any four: 20 Marks

munotes.in 1

A)What is lambda function? Explain it with the help of an example.[5]

Answer

For full marks, cover: the definition of a lambda function; its syntax; a program with output; how a lambda differs from a def function; where lambdas are used (sort keys, filter, map); its limits.

What a lambda function is

A lambda function is a small function with no name, written in one line with the keyword lambda. It is also called an anonymous function. It can take any number of arguments, but its body is a single expression. The value of that expression is returned automatically.

Syntax

lambda arguments: expression

The arguments come before the colon and the expression after it. There is no return keyword, because the expression itself is the result. A lambda is usually assigned to a name or passed straight to another function.

Example program

  1. square = lambda x: x * x
munotes.in 2
  1. add = lambda a, b: a + b
  2. print(square(6), add(3, 4))
  3. marks = [("Asha", 72), ("Ravi", 58), ("Meera", 91)]
  4. marks.sort(key=lambda s: s[1])
  5. print(marks)
  6. nums = [1, 2, 3, 4, 5, 6]
  7. print(list(filter(lambda n: n % 2 == 0, nums)))
  8. print(list(map(lambda n: n * 10, nums)))

Output:

36 7
[('Ravi', 58), ('Asha', 72), ('Meera', 91)]
[2, 4, 6]
[10, 20, 30, 40, 50, 60]

How the example works

  1. square takes one argument and returns its square, so square(6) is 36. add takes two arguments and returns 7.
  2. In line 5 the lambda picks the second item of each pair. So the list is sorted by marks, from 58 to 91.
  3. filter() keeps the items for which the lambda gives True, which are the even numbers.
  4. map() applies the lambda to every item, so each number is multiplied by 10.
munotes.in 3

Lambda compared with def

Pointlambdadef
Namenone, unless assignedalways named
Bodyone expressionany number of statements
returnautomaticwritten with return
Typical usea short function used oncea function used many times

Limits

A lambda cannot hold statements such as if blocks, loops or assignments. It may use a conditional expression, for example lambda n: "even" if n % 2 == 0 else "odd". Anything longer should be written with def, because it is easier to read and test.

Conclusion. A lambda function is an anonymous one-expression function written as lambda arguments: expression. It returns its expression's value, and it is most useful as a short key or rule passed to sort(), filter() or map().

munotes.in 4

The rest of the answers

The first answer is free. The rest come with the B.Sc. (Computer Science) Semester 1 solved papers.

You have read the question paper and its first answer in full. Buy the solved papers once and you can read every answer of every solved paper in this semester.

Notes + practical solutions + solved papers: ₹798 Already bought it? Sign in

Or solved papers only: ₹499
Or notes + practical solutions: ₹499

The question paper itself stays free, and so does the syllabus.

Issue

Found an error in this volume? Report it and we will check it against the paper.

Done!