Programming Concepts

10 min
Video + Practice
SC-40

Target Objective

Write simple programs using variables, loops, and functions

Programming Concepts

When you open a popular Nepali app like Pathao or Fonepay, what makes it work? It's not magic—it's programming. Programming is simply writing a set of instructions for the computer to follow. In Grade 11 Science, you will typically be introduced to either C language or Python.

The Core Building Blocks

No matter which language you use, almost all programming languages share five fundamental concepts:

1. Variables and Data Types

A variable is like a labelled container in memory where you store data. Just like you wouldn't put soup in an envelope, different types of data need different variable types:

  • Integer (int): Whole numbers (e.g., your SEE percentage like 85).
  • Float (float): Decimal numbers (e.g., petrol price like 167.50).
  • Character (char/str): Single letters or text (e.g., student name "Aayush").

2. Control Structures (If/Else Conditions)

Programs need to make decisions based on rules. Example: IF your marks are greater than 80, print "Distinction", ELSE print "First Division". This is exactly how the NEB grading system is automated!

3. Loops (Repetition)

Computers are great at doing repetitive tasks without complaining. A loop runs the same block of code multiple times.

  • For loop: Used when you know exactly how many times to repeat (e.g., print "Hello Nepal" 10 times).
  • While loop: Used when you want to repeat until a certain condition stops being true (e.g., keep asking for a password until it's correct).

4. Functions

Imagine you are building a calculator. Instead of rewriting the addition code every time, you write a single block of code called a function named addNumbers(a, b), and you can reuse it whenever you need it. Functions make code clean, reusable, and easy to maintain.

Example in Python (A simple greeting):

def greet_student(name):
    print("Namaste, " + name + "! Welcome to Grade 11.")

greet_student("Priya")

Quick Quiz

1. Which of the following data types would you use to store a student's exact GPA (e.g., 3.65)?

2. What is the primary purpose of a 'Loop' in programming?

3. In programming, what is a 'variable'?

4. Which feature of programming allows you to write a block of code once and reuse it anywhere in your program?