SEESathi
HomeSubjectsPast PapersMock TestSavedSearch
SEESathi

Empowering every Class 10 student across Nepal with world-class, beautifully structured study notes and solved questions.

Study

  • Master Notes
  • Question Bank
  • Past Papers

Subjects

  • Science & Technology
  • English
  • नेपाली
  • Social Studies
  • Computer Science
  • Mathematics

Resources

  • SEE Grading Guide
  • Syllabus Breakdown
  • Topper Answer Sets
  • Mock Test Simulator

Legal

  • About Mission
  • Editorial Board
  • Privacy Policy
  • Terms of Use

© 2026 SEE Sathi Technologies Pvt. Ltd. Kathmandu, Nepal.

Built for every Class 10 student across Nepal

Python — Modules, Packages & LibrariesSolved Questions· Unit 4
Computer Science · Chapter 04c
67 solved questions

Programming In Python - 4.3 Concept Of Modules, Packages and Library

Every question in this chapter, answered and explained — step-by-step solutions drawn live from the chapter library across 5 question sections.

Section C: Output Tracing Practice (Selected Self-Practice Programs)19Section D: Programming Practice (Selected Lab Activity Exercises)18Section E: Additional SEE-Style Practice10Concept in Practice 3 — Python Libraries10Concept in Practice 4 — Turtle Graphics10
01

Section C: Output Tracing Practice (Selected Self-Practice Programs)

19
1Textbookcs3-q1

[Sequential Flow] Find the output with dry run: x = 10 y = 4 z = x - y w = z + 6 print("Result:", w)

Ans.Dry Run: x=10, y=4, z=x-y=6, w=z+6=12. Output: Result: 12
2Textbookcs3-q2

[Sequential Flow] Find the output with dry run: c = 25 f = (c * 9/5) + 32 print("Fahrenheit =", f)

Ans.Dry Run: c=25, f=(25*9/5)+32 = 45+32 = 77.0. Output: Fahrenheit = 77.0
3Textbookcs3-q3

[Sequential Flow] Find the output with dry run: p = 1000 r = 5 t = 2 si = (p * r * t) / 100 print("Si =", si)

Ans.Dry Run: p=1000, r=5, t=2, si=(1000*5*2)/100 = 10000/100 = 100.0. Output: Si = 100.0
4Textbookcs3-q4

[Conditional Structure] Find the output with dry run: n = 12 if n > 0: print("Positive") print("End")

Ans.Dry Run: n=12, 12>0 is True so "Positive" is printed, then "End" is printed (not inside the if, so it always runs). Output: Positive End
5Textbookcs3-q5

[Conditional Structure] Find the output with dry run: t = 32 if t >= 40: print("Hot") elif t >= 25: print("Warm") else: print("Cold")

Ans.Dry Run: t=32; 32>=40 is False; 32>=25 is True, so the elif branch runs. Output: Warm
6Textbookcs3-q6

[Conditional Structure] Find the output with dry run: y = 2024 if y % 400 == 0 or (y % 4 == 0 and y % 100 != 0): print("Leap Year") else: print("Not Leap Year")

Ans.Dry Run: y=2024; 2024 % 400 = 24 (not 0); check second condition: 2024 % 4 == 0 (True) and 2024 % 100 != 0 (True, since 2024 % 100 = 24), so the overall condition is True. Output: Leap Year
7Textbookcs3-q7

[Loop Structure] Find the output with dry run: for i in range(1, 6): print(3, "x", i, "=", 3 * i)

Ans.Dry Run: i takes values 1 to 5; the loop prints 3 x i = 3*i each time. Output: 3 x 1 = 3 3 x 2 = 6 3 x 3 = 9 3 x 4 = 12 3 x 5 = 15
8Textbookcs3-q8

[Loop Structure] Find the output with dry run: i = 2 while i <= 10: print(i) i = i + 2

Ans.Dry Run: i starts at 2 and increases by 2 each time while i<=10, so i takes values 2,4,6,8,10. Output: 2 4 6 8 10
9Textbookcs3-q9

[Loop Structure] Find the output with dry run: w = "PYTHON" c = 0 for x in w: c = c + 1 print("Total =", c)

Ans.Dry Run: the for loop iterates once for each character in "PYTHON" (6 characters), incrementing c each time, so c ends at 6. Output: Total = 6
10Textbookcs3-q10

[Loop Structure] Find the output with dry run: n = [2, 3, 4] p = 1 for x in n: p = p * x print("Product =", p)

Ans.Dry Run: p starts at 1; p = 1*2=2, then 2*3=6, then 6*4=24. Output: Product = 24
11Textbookcs3-q11

[Nested Loop] Find the output with dry run: i = 5 while i >= 1: j = i while j >= 1: print(j, end=" ") j = j - 1 print() i = i - 1

Ans.Dry Run: the outer while runs for i = 5,4,3,2,1. For each i, the inner while prints j from i down to 1, then a newline is printed. Output: 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1
12Textbookcs3-q12

[Nested Loop] Find the output with dry run: for i in range(1, 4): for j in range(1, 4): print(i*j, end=" ") print()

Ans.Dry Run: for i=1,2,3 and j=1,2,3, the program prints i*j on the same line for each i, then moves to a new line. Output: 1 2 3 2 4 6 3 6 9
13Textbookcs3-q13

[User-Defined Function] Find the output: def cube(n): return n**3 a = 2 b = cube(a) print(b)

Ans.Dry Run: a=2, cube(2) returns 2**3 = 8, so b=8. Output: 8
14Textbookcs3-q14

[User-Defined Function] Find the output: def check_even(n): if n % 2 == 0: return "Even" else: return "Odd" print(check_even(9))

Ans.Dry Run: check_even(9): 9 % 2 == 0 is False, so the function returns "Odd". Output: Odd
15Textbookcs3-q15

[User-Defined Function] Find the output: def grade(marks): if marks >= 80: return "A" elif marks >= 60: return "B" else: return "C" print(grade(72))

Ans.Dry Run: grade(72): 72>=80 is False; 72>=60 is True, so the function returns "B". Output: B
16Textbookcs3-q16

[User-Defined Function] Find the output: def sum_digits(n): s = 0 while n > 0: d = n % 10 s = s + d n = n // 10 return s num = 253 print(sum_digits(num))

Ans.Dry Run: sum_digits(253): d=3,s=3,n=25 -> d=5,s=8,n=2 -> d=2,s=10,n=0; loop ends since n is not > 0. Output: 10
17Textbookcs3-q17

[User-Defined Function] Find the output: def is_armstrong(n): s = 0 t = n while t > 0: d = t % 10 s += d ** 3 t //= 10 return s == n num = 153 print(is_armstrong(num))

Ans.Dry Run: is_armstrong(153): digits are 1,5,3; 1**3+5**3+3**3 = 1+125+27 = 153, which equals n, so the function returns True. Output: True
18Textbookcs3-q18

[User-Defined Function] Find the output: def triangle_type(a, b, c): if a == b and b == c: return "Equilateral Triangle" elif a == b or b == c or a == c: return "Isosceles Triangle" else: return "Scalene Triangle" x = 5 y = 5 z = 5 r = triangle_type(x, y, z) print(r)

Ans.Dry Run: triangle_type(5,5,5): a==b and b==c is True (5==5 and 5==5), so the function returns "Equilateral Triangle". Output: Equilateral Triangle
19Textbookcs3-q19

[User-Defined Function] Find the output: def right_triangle(a, b, c): if a*a + b*b == c*c: return "The triangle is Right-angled." else: return "The triangle is Not right-angled." x = 3 y = 4 z = 5 r = right_triangle(x, y, z) print(r)

Ans.Dry Run: right_triangle(3,4,5): 3*3 + 4*4 = 9+16 = 25, and 5*5 = 25, so the condition is True, and the function returns "The triangle is Right-angled." Output: The triangle is Right-angled.
02

Section D: Programming Practice (Selected Lab Activity Exercises)

18
1Textbookcs4-q1

Write a Python program to input two numbers and display their sum, difference, product, quotient, remainder, and power (the first number raised to the second).

Ans.Program: a = 12 b = 5 print("Sum =", a + b) print("Difference =", a - b) print("Product =", a * b) print("Quotient =", a / b) print("Remainder =", a % b) print("Power =", a ** b) Output (for a=12, b=5): Sum = 17 Difference = 7 Product = 60 Quotient = 2.4 Remainder = 2 Power = 248832
2Textbookcs4-q2

Write a program to display the multiplication table of a number entered by the user.

Ans.Program: num = 7 for i in range(1, 11): print(num, "x", i, "=", num * i) Output (for num=7): 7 x 1 = 7 7 x 2 = 14 7 x 3 = 21 7 x 4 = 28 7 x 5 = 35 7 x 6 = 42 7 x 7 = 49 7 x 8 = 56 7 x 9 = 63 7 x 10 = 70
3Textbookcs4-q3

Create a program that takes numbers from the user and stores them in a list. Separate even and odd numbers into two different lists, then print both lists.

Ans.Program: numbers = [12, 7, 18, 23, 30] even_list = [] odd_list = [] for n in numbers: if n % 2 == 0: even_list.append(n) else: odd_list.append(n) print("Even numbers:", even_list) print("Odd numbers:", odd_list) Output: Even numbers: [12, 18, 30] Odd numbers: [7, 23]
4Textbookcs4-q4

Create a Python program using a function to convert temperature from Celsius to Fahrenheit. Use the formula (Celsius x 9/5) + 32.

Ans.Program: def celsius_to_fahrenheit(celsius): f = (celsius * 9/5) + 32 return f c = 30 result = celsius_to_fahrenheit(c) print("Fahrenheit =", result) Output: Fahrenheit = 86.0
5Textbookcs4-q5

Write a Python program with a function to calculate the cube of a number.

Ans.Program: def cube(n): return n * n * n num = 4 print("Cube of", num, "is", cube(num)) Output: Cube of 4 is 64
6Textbookcs4-q6

Create a Python program using a function to convert the total number of days into years, weeks, and remaining days (1 year = 365 days, 1 week = 7 days).

Ans.Program: def convert_days(total_days): years = total_days // 365 remaining = total_days % 365 weeks = remaining // 7 days = remaining % 7 return years, weeks, days y, w, d = convert_days(400) print("Years:", y, "Weeks:", w, "Days:", d) Output (for 400 days): Years: 1 Weeks: 5 Days: 0
7Textbookcs4-q7

Write a function that defines a local variable message with the value "Hello, Students!" and prints it inside the function.

Ans.Program: def show_message(): message = "Hello, Students!" print("Inside function:", message) show_message() Output: Inside function: Hello, Students! Note: message is a local variable, so it cannot be accessed or printed outside show_message().
8Textbookcs4-q8

Create a program with a global variable count = 0. Write a function increment() that adds 1 to count and displays it using the global keyword. Call the function twice.

Ans.Program: count = 0 def increment(): global count count += 1 print("Count:", count) increment() increment() Output: Count: 1 Count: 2
9Textbookcs4-q9

Write a function using a positional parameter to calculate the area of a rectangle, given its length and breadth.

Ans.Program: def area_rectangle(length, breadth): return length * breadth print("Area:", area_rectangle(10, 4)) Output: Area: 40
10Textbookcs4-q10

Write a function to calculate the area of a circle with a default value for pi, so that the caller may optionally supply a more precise value.

Ans.Program: def area_circle(radius, pi=3.14): return pi * radius * radius print("Area with default pi:", area_circle(7)) print("Area with custom pi:", area_circle(7, 3.14159)) Output: Area with default pi: 153.86 Area with custom pi: 153.93791
11Textbookcs4-q11

Write a function to display a student's name, roll number, and grade using keyword arguments.

Ans.Program: def student_details(name, roll, grade): print("Name:", name, "Roll:", roll, "Grade:", grade) student_details(grade="A", name="Sabin", roll=12) Output: Name: Sabin Roll: 12 Grade: A
12Textbookcs4-q12

Write a function using variable-length parameters (*args) to find the largest number from any number of numbers passed to it.

Ans.Program: def find_largest(*numbers): largest = numbers[0] for n in numbers: if n > largest: largest = n return largest print("Largest:", find_largest(4, 19, 7, 25, 3)) Output: Largest: 25
13Textbookcs4-q13

Write a function that takes a number as an argument and prints its square root.

Ans.Program: import math def show_sqrt(n): print("Square root of", n, "is", math.sqrt(n)) show_sqrt(49) Output: Square root of 49 is 7.0
14Textbookcs4-q14

Write a function that takes a dictionary containing a book's title and author, then prints them.

Ans.Program: def show_book(book): print("Title:", book["title"]) print("Author:", book["author"]) book = {"title": "Karnali Blues", "author": "Buddhisagar"} show_book(book) Output: Title: Karnali Blues Author: Buddhisagar
15Textbookcs4-q15

Write a function that takes two numbers and returns their sum.

Ans.Program: def add_two(a, b): return a + b result = add_two(15, 27) print("Sum:", result) Output: Sum: 42
16Textbookcs4-q16

Write a function that takes the base and height of a triangle and returns its area.

Ans.Program: def triangle_area(base, height): return 0.5 * base * height area = triangle_area(10, 6) print("Area of triangle:", area) Output: Area of triangle: 30.0
17Textbookcs4-q17

Create a module calculator.py with two functions, square(num) and cube(num). Show how another program would import this module and display the square and cube of a number.

Ans.Module file calculator.py: def square(num): return num * num def cube(num): return num ** 3 Main program (imports the module): import calculator n = 4 print("Square of", n, "is", calculator.square(n)) print("Cube of", n, "is", calculator.cube(n)) Output: Square of 4 is 16 Cube of 4 is 64
18Textbookcs4-q18

Create a package geometry with a module area.py containing functions rectangle_area(l, b) and circle_area(r). Show how a program would use these functions.

Ans.Module file geometry/area.py: def rectangle_area(l, b): return l * b def circle_area(r): return 3.14 * r * r Main program (imports the package module): from geometry import area print("Rectangle area:", area.rectangle_area(8, 5)) print("Circle area:", area.circle_area(7)) Output: Rectangle area: 40 Circle area: 153.86 Note: the geometry folder must also contain an empty __init__.py file to be recognized as a package.
03

Section E: Additional SEE-Style Practice

10
1Textbookcs5-q1

Define a function in Python. Write any two advantages of using functions.

Ans.A function is a block of reusable code designed to perform a specific task, defined using the def keyword. Two advantages: (i) Code Reusability — the same function can be called multiple times instead of rewriting the code. (ii) Modularity — a large program can be broken into smaller, manageable parts, which also makes debugging easier.
2Textbookcs5-q2

Differentiate between local scope and global scope.

Ans.Local scope refers to a variable declared inside a function; it can be accessed only within that function and is destroyed once the function ends. Global scope refers to a variable declared outside all functions; it can be accessed from anywhere in the program, including inside functions, and stays in memory until the program ends. To modify a global variable inside a function, the global keyword must be used.
3Textbookcs5-q3

Write a program using continue to print only the odd numbers from 1 to 7.

Ans.Program: for i in range(1, 8): if i % 2 == 0: continue print(i, end=" ") Output: 1 3 5 7
4Textbookcs5-q4

Find the error in the following program and correct it: def is_prime(n): if n < 2: return False for i in range(2, n+1): if n % i == 0: return False return True print(is_prime(17))

Ans.Error: the for loop uses range(2, n+1), which includes n itself; since any number n is divisible by n, this makes the function incorrectly return False even for prime numbers. Corrected program: def is_prime(n): if n < 2: return False for i in range(2, n): if n % i == 0: return False return True print(is_prime(17)) # True print(is_prime(15)) # False
5Textbookcs5-q5

Write a function using variable-length parameters (*args) that calculates the average of any number of values passed to it.

Ans.Program: def average(*nums): return sum(nums) / len(nums) print("Average:", average(10, 20, 30, 40)) Output: Average: 25.0
6Textbookcs5-q6

What will be the output of the following program? text = "SEE Exam" print(text.lower()) print(text.upper()) print(len(text))

Ans.Dry Run: lower() converts to lowercase, upper() converts to uppercase, and len() counts all characters including the space ("SEE Exam" has 8 characters). Output: see exam SEE EXAM 8
7Textbookcs5-q7

Write a function get_squares(n) that returns a list containing the squares of the first n natural numbers.

Ans.Program: def get_squares(n): result = [] for i in range(1, n+1): result.append(i*i) return result print(get_squares(5)) Output: [1, 4, 9, 16, 25]
8Textbookcs5-q8

What will be the output of the following nested loop with a break statement? for i in range(1, 4): for j in range(1, 4): if j == 2: break print(i, j)

Ans.Dry Run: for each value of i (1,2,3), the inner loop starts at j=1 and prints (i, 1); when j becomes 2, the break statement stops the inner loop immediately, so only one line is printed per outer iteration. Output: 1 1 2 1 3 1
9Textbookcs5-q9

Write any four differences between a module and a package in Python.

Ans.Differences: (i) A module is a single .py file, while a package is a folder containing multiple related modules. (ii) A module is imported directly with import module_name, while a package additionally requires an __init__.py file inside its folder. (iii) A module typically holds a small set of related functions or variables, while a package organizes many modules together for larger programs. (iv) Functions from a module are accessed as module_name.function_name; functions from a package's module are accessed as module_name.function_name after importing that module from the package (e.g. from package_name import module_name).
10Textbookcs5-q10

Write a function that takes a Boolean value as an argument and prints "Eligible" if True and "Not Eligible" if False.

Ans.Program: def check_eligibility(is_eligible): if is_eligible: print("Eligible") else: print("Not Eligible") check_eligibility(True) check_eligibility(False) Output: Eligible Not Eligible
04

Concept in Practice 3 — Python Libraries

10
1Textbookcs1-q1

What is a Python library?

Ans.b) A collection of functions, modules, and packages that can be reused
2Textbookcs1-q2

Which of the following is used to import the entire math library in Python?

Ans.c) import math
3Textbookcs1-q3

What does the math.sqrt() function do?

Ans.b) Returns the square root of a number
4Textbookcs1-q4

Which function from the random library is used to generate a random integer between two values?

Ans.b) random.randint()
5Textbookcs1-q5

What is the correct way to import only the sqrt function from the math library?

Ans.a) from math import sqrt
6Textbookcs1-q6

What is the use of the pandas library in Python?

Ans.c) Handling and analyzing data
7Textbookcs1-q7

Which of the following libraries is used for drawing shapes like squares and circles in Python?

Ans.b) turtle
8Textbookcs1-q8

What is the use of matplotlib in Python?

Ans.a) Data plotting and visualization
9Textbookcs1-q9

Which command is used to install external libraries in Python?

Ans.b) pip install
10Textbookcs1-q10

In which of the following cases would you use random.choice()?

Ans.b) To select a random item from a list
05

Concept in Practice 4 — Turtle Graphics

10
1Textbookcs2-q1

What is the primary purpose of the Turtle library in Python?

Ans.b) To create graphics and drawings using a turtle cursor
2Textbookcs2-q2

Which Turtle function moves the turtle forward by a specified number of units?

Ans.b) t.forward()
3Textbookcs2-q3

Which function would you use to lift the pen so the turtle moves without drawing?

Ans.a) penup()
4Textbookcs2-q4

What does the following code do? t.fillcolor("blue"); t.begin_fill(); # draw a square; t.end_fill()

Ans.c) Draws a shape and fills it with blue color
5Textbookcs2-q5

Which Turtle function sets the shape of the turtle cursor?

Ans.a) t.shape()
6Textbookcs2-q6

What will this code draw? for i in range(3): t.forward(100); t.right(120)

Ans.b) A triangle
7Textbookcs2-q7

Which of the following is NOT a valid turtle function?

Ans.b) turnleft()
8Textbookcs2-q8

Which function in the Turtle library is used to change both the pen and fill color together?

Ans.b) color()
9Textbookcs2-q9

What will this code do? t.penup(); t.forward(100); t.pendown(); t.circle(50)

Ans.b) Move forward 100 units without drawing, then draw a circle
10Textbookcs2-q10

Which function stops filling the shape with color in Turtle graphics?

Ans.b) end_fill()
Review the NotesBack to Chapter