Unit 4 Practicals | Programming in Python Class 10
Programming in Python
Type code, run it, make mistakes, fix them and build small fun programs with libraries.
These practicals are made for live coding, trying, breaking, fixing and running small Python programs with your own hands.
- Open Python shell or a code editor.
- Type one print statement and run it.
- Change one value and run it again.
- Show your result to a friend or teacher.
- Run a small code line by line in front of the class.
- Fix a program that has a mistake in it.
- Write one function and test it with different inputs.
- Use a library such as turtle, pandas or matplotlib to make something fun.
- Quizzes and tests on syntax, functions, loops and libraries.
- Peer evaluation of code sessions and debugging tasks.
- Presentation of a small project or a fun library-based program.
- Make a small program that asks name and age, then prints a message.
- Break the program once, then fix it and explain the error.
- Install Python 3 (https://python.org) and optionally create a virtualenv:
python3 -m venv venv source venv/bin/activate
- Install common packages:
pip install pandas matplotlib
name = input('Your name: ')
age = int(input('Your age: '))
print(f'Hello {name}, in 5 years you will be {age+5}')
def factorial(n):
result = 1
for i in range(2, n+1):
result *= i
return result
print(factorial(5))
- Create a file
square.pywith the turtle code below and run it with IDLE orpython3 square.py.import turtle screen = turtle.Screen() pen = turtle.Turtle() for _ in range(4): pen.forward(100) pen.left(90) screen.mainloop()
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()
- Build a small CLI program that reads students.csv and prints average score and top student.
- Optional: add a plot and save it as PNG.
- Debugged code file with comments explaining the fix.
- One small program using a library such as turtle, pandas or matplotlib.
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.
LinkedIn ProfileRelated Posts
Loading related posts…
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...