Unit 4 Practicals | Programming in Python Class 10

Unit 4 Practicals | Programming in Python Class 10
Unit 4 Practical Sheet

Programming in Python

Type code, run it, make mistakes, fix them and build small fun programs with libraries.

Shell Functions Debugging Turtle Pandas
← Back to Syllabus

These practicals are made for live coding, trying, breaking, fixing and running small Python programs with your own hands.

Do first
  1. Open Python shell or a code editor.
  2. Type one print statement and run it.
  3. Change one value and run it again.
  4. Show your result to a friend or teacher.
Do in class
  1. Run a small code line by line in front of the class.
  2. Fix a program that has a mistake in it.
  3. Write one function and test it with different inputs.
  4. Use a library such as turtle, pandas or matplotlib to make something fun.
Evaluation techniques
  1. Quizzes and tests on syntax, functions, loops and libraries.
  2. Peer evaluation of code sessions and debugging tasks.
  3. Presentation of a small project or a fun library-based program.
Mini challenge
  1. Make a small program that asks name and age, then prints a message.
  2. Break the program once, then fix it and explain the error.
Setup
  1. Install Python 3 (https://python.org) and optionally create a virtualenv:
    python3 -m venv venv
    source venv/bin/activate
  2. Install common packages:
    pip install pandas matplotlib
Task 1 — Basics & input
name = input('Your name: ')
age = int(input('Your age: '))
print(f'Hello {name}, in 5 years you will be {age+5}')
Task 2 — Functions & factorial
def factorial(n):
    result = 1
    for i in range(2, n+1):
        result *= i
    return result

print(factorial(5))
Task 3 — Turtle graphics
  1. Create a file square.py with the turtle code below and run it with IDLE or python3 square.py.
    import turtle
    screen = turtle.Screen()
    pen = turtle.Turtle()
    for _ in range(4):
        pen.forward(100)
        pen.left(90)
    screen.mainloop()
    
Task 4 — Pandas & Matplotlib
import pandas as pd
import matplotlib.pyplot as plt

df = pd.DataFrame({'name':['Asha','Ramesh','Sita'], 'score':[80,75,92]})
df.to_csv('students.csv', index=False)

plt.bar(df['name'], df['score'])
plt.title('Scores')
plt.show()
Mini project
  1. Build a small CLI program that reads students.csv and prints average score and top student.
  2. Optional: add a plot and save it as PNG.
Suggested student output
  1. Debugged code file with comments explaining the fix.
  2. One small program using a library such as turtle, pandas or matplotlib.
Netra Koirala

Netra Koirala

Computer Science Educator

Passionate computer science educator and author. Provides free study notes, practical guides, and tutorials for Class 9, 10, 11, 12, and B.Sc CSIT students in Nepal. Years of teaching experience in computer science fundamentals.

Computer Science notes, tutorials, MCQs, and educational resources for Nepal students. Covering Class 9, SEE preparation, Class 11, Class 12, SLC, programming, DBMS, networking, HTML, JavaScript, PHP, OOP and more.

Featured Post

Grade 10 Computer Science: Specification Grid & Model Questions

Specification Grid & Model Questions of Computer Science | Grade 10 📚 Examination Resource Specification Grid & M...

Followers