Sikshya Plus Get appGet the app free
Class 10 · Computer Science

Programming in Python – Class 10 Computer Science Notes and Solutions

Complete solutions and answers for “Programming in Python”, a chapter in Class 10 Computer Science (SEE exam preparation). This page covers The lesson in short, Section A: Python Fundamentals, Data Types, and Operators, Section B: Control Flow: Decision Making and Loops and Section C: Solved Python Textbook Programs.

  • Free, no login needed
  • 3 min read
  • Updated 20 November 2026

Chapter at a glance

Comprehensive solutions and programming exercises for Class 10 Computer Science Unit 4 Programming in Python, covering data types, arithmetic and logical operators, control flow (if-elif-else, loops), and complete solved Python scripts.

  • Python Syntax, Indentation, and Data Types
  • Operators: Arithmetic, Relational, Logical
  • Conditional Selection: if, elif, and else
  • Iteration with for loops and while loops
  • Standard Algorithms: Factorial, Prime Check, Fibonacci

Exam focus: Understanding Python indentation rules, tracing output of loops and conditions, and writing correct Python code for prime numbers, factorials, and series generation.

Key formulas and definitions

  • Modulo operator: n % 2 == 0 for even check
  • Square root optimization: int(n ** 0.5) + 1 for prime testing
On this page (12 sections)
  1. The lesson in short
  2. Section A: Python Fundamentals, Data Types, and Operators
  3. Data TypesCore Data Types in Python
  4. OperatorsStandard Operators in Python
  5. Section B: Control Flow: Decision Making and Loops
  6. ConditionalsConditional Branching: if, elif, and else
  7. LoopsIterative Loops: for and while
  8. Section C: Solved Python Textbook Programs
  9. Code 1Program 1: Check whether a Number is Odd or Even
  10. Code 2Program 2: Calculate the Factorial of a Positive Integer
  11. Code 3Program 3: Check Prime Number
  12. Code 4Program 4: Generate the Fibonacci Series up to N Terms

Solutions and answers

Class 10 Computer Science · Unit 4: Programming in Python

The lesson in short

Python is a high-level, interpreted, dynamically-typed programming language renowned for its elegant, readable syntax, vast standard library, and multi-paradigm flexibility.

Widely deployed in web development, scientific computing, Artificial Intelligence, automation scripting, and educational instruction, Python emphasizes programmer productivity and code clarity.

This comprehensive chapter covers Python syntax rules, basic data types (int, float, str, bool, list), operators, conditional selection statements (if-elif-else), iterative loops (for, while), user-defined functions, and complete solved CDC programming exercises.

Section A: Python Fundamentals, Data Types, and Operators

Data TypesCore Data Types in Python

Data TypeKeywordDescriptionExample Literals
IntegerintWhole numbers without decimal fractionsx = 42, count = -15
Floating PointfloatReal numbers containing decimal pointspi = 3.14159, g = 9.8
StringstrOrdered sequence of Unicode characters enclosed in quotesname = "Kathmandu", msg = 'Nepal'
BooleanboolLogical values representing truth stateflag = True, is_prime = False
ListlistOrdered, mutable collection of heterogeneous itemsnums = [10, 20, 30], mixed = [1, "apple", True]

OperatorsStandard Operators in Python

Operator CategorySymbolsOperation DescriptionExample Code & Result
Arithmetic+, -, *, /, //, %, **Basic math operations; // is integer floor division, ** is exponentiation17 // 3 -> 5; 2 ** 4 -> 16
Relational / Comparison==, !=, <, >, <=, >=Compares two operands; evaluates to True or False10 >= 5 -> True; 7 == 9 -> False
Logicaland, or, notCombines boolean expressions based on truth logicTrue and False -> False; not False -> True
Assignment=, +=, -=, *=, /=Assigns and modifies variable values in placex += 5 is equivalent to x = x + 5

Section B: Control Flow: Decision Making and Loops

ConditionalsConditional Branching: if, elif, and else

Python uses indentation (four spaces) rather than curly braces to define code blocks. Example of multi-way conditional structure:

StructureSyntax FormOperational Explanation
if Statementif condition: # codeExecutes body only if test expression is True
if-elseif condition: # A else: # BExecutes block A if True, block B if False
if-elif-elseif cond1: # 1 elif cond2: # 2 else: # 3Tests cascading conditions sequentially until one evaluates True

LoopsIterative Loops: for and while

The for loop: Iterates through items in any iterable sequence (such as a list or a range): `for i in range(1, 6): print(i)` outputs numbers 1 through 5.

The while loop: Repeatedly executes statements as long as a test condition remains True: `while n > 0: n -= 1`.

Section C: Solved Python Textbook Programs

Code 1Program 1: Check whether a Number is Odd or Even

Write a Python program to input an integer and determine if it is odd or even.

# Program to check Odd or Even

num = int(input("Enter an integer: "))

if num % 2 == 0:

print(f"{num} is an Even number.")

else:

print(f"{num} is an Odd number.")

Code 2Program 2: Calculate the Factorial of a Positive Integer

Write a Python program to calculate the factorial of a user-supplied integer.

# Program to find Factorial

n = int(input("Enter a positive integer: "))

fact = 1

if n < 0:

print("Factorial does not exist for negative numbers.")

else:

for i in range(1, n + 1):

fact *= i

print(f"The factorial of {n} is {fact}.")

Code 3Program 3: Check Prime Number

Write a Python program to verify whether a given number is Prime or Composite.

# Program to verify Prime Number

n = int(input("Enter a number: "))

if n <= 1:

print(f"{n} is neither prime nor composite.")

else:

is_prime = True

for i in range(2, int(n ** 0.5) + 1):

if n % i == 0:

is_prime = False

break

if is_prime:

print(f"{n} is a Prime number.")

else:

print(f"{n} is a Composite number.")

Code 4Program 4: Generate the Fibonacci Series up to N Terms

Write a Python program to print the first N terms of the Fibonacci sequence.

# Fibonacci Series generator

n = int(input("How many terms? "))

a, b = 0, 1

print("Fibonacci Series:")

for _ in range(n):

print(a, end=" ")

a, b = b, a + b

print() # newline

Frequently asked questions

What is Programming in Python about?

Comprehensive solutions and programming exercises for Class 10 Computer Science Unit 4 Programming in Python, covering data types, arithmetic and logical operators, control flow (if-elif-else, loops), and complete solved Python scripts.

Which topics are covered in Programming in Python?

Class 10 Computer Science “Programming in Python” covers: Python Syntax, Indentation, and Data Types; Operators: Arithmetic, Relational, Logical; Conditional Selection: if, elif, and else; Iteration with for loops and while loops; Standard Algorithms: Factorial, Prime Check, Fibonacci.

What should I focus on in Programming in Python for the exam?

Understanding Python indentation rules, tracing output of loops and conditions, and writing correct Python code for prime numbers, factorials, and series generation.

What are the key formulas or definitions in Programming in Python?

Modulo operator: n % 2 == 0 for even check; Square root optimization: int(n ** 0.5) + 1 for prime testing.

Where can I read the Class 10 Computer Science “Programming in Python” solutions?

Right on this page. They are free and you do not need to sign up. For chapter quizzes and the AI tutor, install the Sikshya Plus app.

Study tips

Free for Class 9 to 12

Do not just read it. Practice it.

You have read the solutions for Programming in Python. Now test yourself, ask the AI tutor and keep your streak going.

Sikshya Plus chapter quiz screen with class, subject and difficulty options
Sikshya AI personal tutor chat inside the app
Sikshya Plus AI tools screen: question assistant, summarizer, translator, grammar checker
Chapter list with Past Q, materials, posts and books tabs
  • AI quizzes for this chapterTest yourself with instant feedback and explanations after every answer.
  • AI tutor, free, 24/7Stuck on a question? Ask in your own words and get a step-by-step explanation.
  • 14 AI tools in one appSummarizer, grammar checker, flashcards, essay help, math solver and more.
  • Past questions and notesPast papers and your own notes organized chapter by chapter.
Download free on Google Play Scan with your phone to install