munotes®

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

Mumbai University Solved Question Papers munotes.in

Introduction to Programming with Python

BSc CS · Sem 1

Nov 2022 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 2022 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 2022 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

Q.1 Answer the following

Attempt any four · 20 Marks

munotes.in 1

a.Explain comments in Python with examples.[5]

Answer

For full marks, cover: what a comment is and why it is written; the single-line and the inline comment; how several lines are commented, and the triple-quoted string; the docstring and how it differs from a comment; a program with output; good practice.

What a comment is

A comment is a note written in a program for a human reader. Python ignores it completely. It is never run and never reaches the bytecode. Comments explain what a part of the program does and, more usefully, why it does it. A comment that only repeats the code is worth nothing; a comment that gives the reason saves the next reader time.

The single-line comment

A comment starts with the hash sign # and runs to the end of the line. It can sit on a line of its own, above the code it explains.

munotes.in 2

The inline comment

A comment can also follow code on the same line. Everything before the # runs; everything after it is ignored. Leave at least two spaces before the #, so the comment stands apart from the code.

Commenting several lines

Python has no multi-line comment like /* ... */ in C. To comment several lines, put a # at the start of each one. IDLE and most editors do this for a selected block in one step.

A triple-quoted string that is not stored anywhere is often used as a multi-line comment. Strictly it is a string that Python builds and throws away, not a comment.

The docstring

A docstring is a string written as the first statement of a function, module or class. Unlike a comment, Python keeps it. It is stored in the object's __doc__ attribute and shown by help().

A program

  1. # Total and average of three marks
  2. marks = [78, 65, 92] # marks out of 100
munotes.in 3
  1. total = sum(marks) # add the three marks
  2. """
  3. This string is not a real comment.
  4. Python builds it and throws it away.
  5. """
  6. def average(values):
  7. """Return the average of a list of numbers."""
  8. return sum(values) / len(values)
  9. print("Total:", total)
  10. print("Roll #7") # the # inside quotes is printed
  11. print("Average:", round(average(marks), 2))
  12. print(average.__doc__)

Output:

Total: 235
Roll #7
Average: 78.33
Return the average of a list of numbers.

Line 1 is a single-line comment, and lines 2, 3 and 12 carry inline comments. None of them appears in the output. A # inside quotes is part of the string, so "Roll #7" is printed in full. The docstring was kept, so average.__doc__ printed it.

munotes.in 4

Good practice

  1. Explain why, not what the code already says.
  2. Keep comments short and up to date with the code.
  3. Use a docstring for every function that others will call.

Conclusion. A comment begins with # and runs to the end of the line, and Python ignores it. Several lines are commented with a # on each, while a docstring is a kept string that __doc__ and help() can read.

munotes.in 5

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!