Skip to main content

Chapter 4 · 16 hours

Programming in Python

SEE past exam questions

Past questions and answers

7 questions set from this chapter. Most repeated first.

  • 2079 · SEE B · Model set · 1 mark

Write appropriate technical term for the following: The process of repeatedly executing some code until a condition is satisfied.

Answer

Looping

Looping is the process of repeating a block of statements again and again until a given condition is satisfied. Examples: FOR, WHILE and DO...WHILE loops.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 1 MCQ

Loading…

  • CDC Class 10 Computer Science model paper, 3031 · 1 mark

Which keyword is used to define a function in Python?
(a) def (b) fun (c) define (d) function

Answer

(a) def

In Python, a function is defined using the def keyword, followed by the function name and parentheses — for example, def add(a, b):. The other options are not Python keywords.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 1 MCQ

Loading…

  • CDC Class 10 Computer Science model paper, 3031 · 1 mark

A student has written the following Python code to check whether a number is even or odd:
num = int(input("Enter a number: "))
if num % 2 == 0:
    print("Even")
else:
    print("Odd")
However, the program shows an error when the user enters a decimal value like 4.5. What is the best modification to make the program more robust?
(a) Replace int() with float() and keep the same condition. (b) Remove the condition num % 2 == 0. (c) Use num / 2 == 0 instead of the modulus operator (%). (d) Remove the input and hardcode the value.

Answer

(a) Replace int() with float() and keep the same condition.

int("4.5") raises a ValueError because int() cannot directly convert a decimal string. Using float() accepts values like 4.5, and the condition num % 2 == 0 still correctly identifies whole even numbers.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • CDC Class 10 Computer Science model paper, 3031 · 2 marks

Write a Python function named area_circle(r) that returns the area of a circle. (Use 3.14)

Answer

def area_circle(r):
    return 3.14 * r * r

The function takes the radius r and returns the area πr2\pi r^2 using π=3.14\pi = 3.14. For example, area_circle(7) returns 3.14×49=153.863.14 \times 49 = 153.86.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • CDC Class 10 Computer Science model paper, 3031 · 2 marks

Write a Python program using try-except to handle ValueError when a user enters a non-numeric value.

Answer

try:
    num = int(input("Enter a number: "))
    print("You entered:", num)
except ValueError:
    print("Invalid input! Please enter a numeric value.")

Explanation: The int() function raises a ValueError if the input cannot be converted to an integer (for example, "abc"). The except ValueError block catches this error and displays a friendly message instead of crashing the program.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • CDC Class 10 Computer Science model paper, 3031 · 2 marks

A teacher shows exam results only in tables, and students find it hard to understand their performance. How can data visualization help solve this problem? Explain with reasons.

Answer

Data visualization means presenting data in pictorial or graphical form — bar graphs, pie charts, line graphs — instead of plain tables of numbers. It can solve the teacher's problem in the following ways:

  • Easy comparison: A bar graph of marks in each subject shows at a glance which subject is strong and which is weak, while in a table the student has to read and compare each number.
  • Quick understanding of trends: A line graph of marks across several exams shows whether performance is improving or falling, which a table cannot show directly.
  • Clear picture of the whole result: A pie chart shows each subject's share of the total marks, so the student instantly sees where most marks came from or were lost.
  • Saves time and reduces confusion: Large amounts of data become simple and interesting, so students understand their performance faster and are motivated to improve.

So, by converting the result table into charts and graphs, the teacher makes performance easy to see, compare and act upon.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • CDC Class 10 Computer Science model paper, 3031 · 2+2 marks

Study the following Python program and answer:
import pandas as pd
data = {'Name':['Asha','Bikash','Chandra'],
'Marks':[45,72,60]}
df = pd.DataFrame(data)
print(df[df['Marks']>=60])
a. Write the output of the above Python code.
b. Modify the code to display students who scored less than 60.

Answer

(a) Output

     Name  Marks
1  Bikash     72
2  Chandra    60

The condition df['Marks']>=60 keeps only the rows where Marks is 60 or more. Bikash (72) and Chandra (60) satisfy it, so those two rows are printed with their original index labels 1 and 2. Asha (45) is dropped.

(b) Modified code

import pandas as pd
data = {'Name':['Asha','Bikash','Chandra'],
'Marks':[45,72,60]}
df = pd.DataFrame(data)
print(df[df['Marks']<60])

Output:

   Name  Marks
0  Asha     45

Only the condition changes from >=60 to <60, so just Asha's row is displayed.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

Questions from CDC Class 10 Computer Science model paper, 3031 (CDC model paper on the new syllabus, 2 hours, with marking scheme), SEE 2082 Computer Science, RE-3031 'A' (Board exam, Chaitra 2082 (scan images); old course, only questions that fit the new outline are used), SEE Grade Increment 2082 Computer Science, GI-3031 (Grade increment paper (4-page scan); old course, month not stated), SEE 2081 Computer Science, RE-3031 (Board exam, 2081 (scan); old course, only questions that fit the new outline are used), SEE 2080 Computer Science, RE-3031 (typed, solved) (Board exam, 2080 (typed with solutions); old course, only questions that fit the new outline are used), CDC SEE Computer Science model question 2080 (CDC model paper (old course), 50 marks; only questions that fit the new outline are used), PABSON SEE Pre-Board 2082 Opt. II Computer Science, 3031 'B' (Pre-board (model) exam, PABSON, 2082-10-29; old course, only questions that fit the new outline are used), PABSON SEE Pre-Board 2082 Opt. II Computer Science, 3031 'C' (Pre-board (model) exam, PABSON, 2082-10-22; old course, only questions that fit the new outline are used), SEE Computer Science Model Sets 1 to 5 (seeqbasicomputer) (Model question sets 1-5 collected on a teacher blog (old course, about 2080); only questions that fit the new outline are used) and SEE Computer Science Technical Terms 1.6 (seeqbasicomputer) (Compilation of 'technical term' questions tagged with the SEE/province/pre-board exams in which they were asked (2073-2080); only questions tagged with a SEE exam are used). Answers are written for this site; check them against your class notes.

Chapter titles and hours from the official syllabus ↗