1st Year Computer Science Chapter 2 Notes: Python Programming (Punjab Board 2026-27)

Complete study notes for ICS/FSc Part 1 Computer Science, Punjab Board (PECTAA/PCTB), Single National Curriculum 2026-27 session.

Chapter 2, Python Programming, follows Introduction to Software Development in the new nine-chapter Computer Science textbook for 1st Year (ICS Part 1 / FSc Part 1 / XI) students under the Single National Curriculum. This is where students write their first real code, covering Python syntax, variables, data types, operators, control structures, and functions — the foundation every later programming-related chapter builds on.

What Is This Chapter About?

This chapter introduces Python, one of the world’s most widely used programming languages, chosen for its simple, readable syntax. Students learn to store and manipulate data, make decisions in code, repeat actions, and organize logic into reusable functions.

Key Topics Covered

1. Introduction to Python

Python is a high-level, general-purpose programming language known for its clean, English-like syntax. It is widely used in web development, data science, automation, and artificial intelligence, which makes it a practical first language for new programmers.

2. Variables and Data Types

A variable is a named location in memory used to store a value that can change during program execution. Python supports several core data types used to represent different kinds of information.

3. Operators

Operators perform actions on values and variables. Python’s main categories are arithmetic operators (+, -, *, /), relational operators (==, !=, >, <), logical operators (and, or, not), and the assignment operator (=).

4. Input and Output

The input() function reads data typed by the user (always as text/string), and the print() function displays output on the screen. Together they let a program interact with its user.

5. Control Structures

Control structures decide the order in which instructions run. The if / elif / else statement makes decisions based on conditions. The for loop repeats a block a fixed number of times (or over a sequence), while the while loop repeats as long as a condition stays true.

6. Functions

A function is a named, reusable block of code defined with the def keyword. Functions can accept input values (parameters) and send back a result using return, which avoids repeating the same code multiple times.

Common Python Data Types

Data TypeExampleDescription
int25Whole numbers
float3.14Decimal (fractional) numbers
str“Hello”Text / string of characters
boolTrue / FalseLogical value
list[1, 2, 3]Ordered collection of items

Sample MCQs

1. Which keyword is used to define a function in Python?

a) func   b) def   c) function   d) define

Answer: b) def

2. What data type does type(5.0) return in Python?

a) int   b) float   c) str   d) bool

Answer: b) float

3. Which loop is used when the number of iterations is known in advance?

a) while   b) for   c) if   d) def

Answer: b) for

4. Which symbol starts a single-line comment in Python?

a) //   b) <!–   c) #   d) **

Answer: c) #

5. What type of value does the input() function return by default?

a) integer   b) float   c) string   d) boolean

Answer: c) string

Important Short Questions

  • Define a variable and give one example.
  • What is the difference between a list and a string in Python?
  • Explain the purpose of the print() function.
  • What is the difference between = and == in Python?
  • Define a function and state why functions are useful.

Important Long Questions

  • Write a Python program that takes a number as input and checks whether it is even or odd, explaining each line.
  • Explain the difference between for and while loops with suitable examples.
  • Describe the concept of functions in Python, including parameters and return values, with an example.
  • Explain Python’s basic data types with an example of each.

How to Prepare This Chapter Effectively

  1. Type out every example program yourself instead of just reading it — muscle memory matters for syntax.
  2. Trace code by hand (write down variable values line by line) before running it, to build debugging instinct.
  3. Practice writing small programs for if/else and loops separately before combining them.
  4. Memorize exact Python keywords and syntax rules — board exams often mark on precise wording.
  5. Attempt the textbook’s end-of-chapter exercises and check your output against expected results.

FAQs

Q: What is Python?

A: Python is a high-level, general-purpose programming language known for simple, readable syntax, widely used in web development, automation, data science, and AI.

Q: Why is Python usually taught first in programming courses?

A: Its syntax closely resembles plain English, which lets beginners focus on logic and problem-solving rather than complex syntax rules.

Q: What is the difference between a variable and a function?

A: A variable stores a single value, while a function is a reusable block of instructions that can take input and produce output.

Q: Is Chapter 2 heavily code-based in the exam?

A: Yes — expect questions asking you to write, trace, or correct short Python programs, not just define terms.

Notes prepared for Punjab Board (PECTAA/PCTB) 1st Year Computer Science, SNC 2026-27 syllabus, Chapter 2: Python Programming.