Class 11 Computer Science Chapter 04 ยท 18 min read

๐Ÿš€ Getting Started with Python

Unit 1 ยท Ch 4 Sep 29, 2026
Chapter Quiz

You've learnt how a computer works INSIDE โ€” now it's time to TALK to it! ๐Ÿ—ฃ๏ธ๐Ÿ’ป But a computer only understands 0s and 1s, and we certainly don't want to write programs in binary. That's where a programming language comes in. This chapter introduces you to Python โ€” the language you will use for the rest of Class 11 AND Class 12. We'll answer: What is Python? Why is it so popular? How does Python run your code? What is the difference between Interactive Mode and Script Mode? Let's write our very first program! ๐Ÿ๐Ÿš€

๐Ÿ’ก How to use these notes

Focus especially on Features (Pluses) and Limitations (Minuses) of Python, Interactive Mode vs Script Mode, and how the Python Interpreter works โ€” these are the favourite 1-mark and 2-mark questions from this chapter!


4.1 ๐Ÿ Introduction

A program is a set of instructions given to a computer to perform a specific task. The language in which we write these instructions is called a programming language.

graph LR
    HUMAN["๐Ÿง‘โ€๐Ÿ’ป Programmer\n(thinks in English)"]
    LANG["๐Ÿ Programming Language\n(Python code)"]
    TRANS["โš™๏ธ Translator\n(Python Interpreter)"]
    MACHINE["๐Ÿ’ป Computer\n(understands only 0s and 1s)"]

    HUMAN --> LANG --> TRANS --> MACHINE

    style LANG fill:#2196F3,color:#fff
    style TRANS fill:#FF9800,color:#fff
    style MACHINE fill:#4CAF50,color:#fff

Programming languages are broadly of two types:

๐Ÿ”ฉ

Low-Level Language

Close to the machine's hardware; difficult for humans to read and write

Machine LanguageAssembly Language
๐Ÿง‘โ€๐Ÿ’ป

High-Level Language

Close to human language (English-like); easy to read, write and debug

PythonJavaC++

Think of it this way: Speaking to a computer in machine language is like talking to someone in a secret code of just 0 and 1. A high-level language like Python lets you speak in near-English, and a translator converts it into the computer's code for you!


4.2 ๐Ÿ What is Python?

Python is a high-level, interpreted, general-purpose, object-oriented programming language. It was created by Guido van Rossum at the National Research Institute for Mathematics and Computer Science (CWI) in the Netherlands, and was first released in February 1991.

๐Ÿ‘จโ€๐Ÿ’ป

Creator

Guido van Rossum, a Dutch programmer

Netherlands
๐Ÿ“…

First Released

Python 0.9.0 was released publicly in 1991

1991
๐ŸŽญ

Name Origin

Named after the BBC comedy show "Monty Python's Flying Circus" โ€” NOT the snake!

Monty Python
๐Ÿ”ข

Current Version

Python 3.x series (Python 3.0 came in 2008; Python 2 ended in 2020)

Python 3

Python is based on (influenced by) two languages:

graph TD
    ABC["๐Ÿ”ค ABC Language\n(simple, teaching language)"]
    MODULA["๐Ÿงฉ Modula-3\n(modules & exceptions)"]
    PY["๐Ÿ PYTHON\n(1991)"]

    ABC --> PY
    MODULA --> PY

    style PY fill:#2196F3,color:#fff
๐Ÿ“‹ Board Exam Tip

"Who developed Python? When was it released?" โ€” 1-mark question! Answer: Python was developed by Guido van Rossum and was released in 1991. It is based on two languages โ€” ABC and Modula-3.

Where is Python used? Almost everywhere!

๐ŸŒ

Web Development

Building websites and web applications

DjangoFlask
๐Ÿค–

AI & Machine Learning

Teaching computers to learn from data

TensorFlowscikit-learn
๐Ÿ“Š

Data Science

Analysing and visualising large amounts of data

PandasMatplotlib
๐ŸŽฎ

Games & Automation

Simple games, scripts that automate boring tasks

Pygamescripts

4.3 โœ… Python โ€” Pluses (Advantages)

Python is loved by beginners AND professionals. Here's why:

๐Ÿ˜Š

Easy to Use

Simple, English-like syntax; programs are short and compact

Great first language
๐Ÿ—ฃ๏ธ

Expressive Language

Fewer lines of code do MORE work compared to other languages

One-line swap of two variables
๐Ÿ”„

Interpreted Language

Code is executed line by line, which makes debugging easy

Errors shown line by line
๐Ÿ”‹

Its Completeness

"Batteries included" โ€” a huge standard library comes built in

mathrandomstatistics
๐Ÿ’ป

Cross-Platform

The same program runs on Windows, Linux, macOS without changes

Platform independent
๐Ÿ†“

Free & Open Source

Free to download and use; its source code is freely available

No licence fee
๐ŸŒ

Variety of Usage

Used for web, AI, data science, games, scientific computing, and more

General purpose

Expressive? See for yourself! Swapping two numbers:

# In Python โ€” just ONE line!
a, b = 5, 10
a, b = b, a
print(a, b)

Output:

10 5

In many other languages, you need a THIRD variable and three separate statements to do the same swap!

๐Ÿง  Memory Trick: "E-E-I-C-C-F-V" ๐Ÿง 

Easy ยท Expressive ยท Interpreted ยท Completeness ยท Cross-platform ยท Free & open source ยท Variety of usage Remember it as: "Every Excited Indian Child Codes For Victory!" ๐Ÿ†


4.4 โŒ Python โ€” Minuses (Limitations)

No language is perfect! Python has a few limitations too:

๐Ÿข

Not the Fastest Language

Being interpreted, Python is slower than fully compiled languages

Slower than C/C++
๐Ÿ”ง

Not Strong on Type-Binding

A variable can hold any type of value; some type mismatch errors are caught only at runtime

x = 5 then x = "five"
๐Ÿ”

Not Easily Convertible

Python's syntax is quite different from other languages, so converting a Python program to another language is not easy

Python โ†’ C is hard
๐Ÿ“ฑ

Lesser Libraries (in some areas)

Compared to older languages like C, Java and Perl, some specialised areas (like mobile app development) have fewer Python libraries

Weak in mobile apps
โš  Common Mistake

Students often write "Python is a compiled language" โ€” โŒ WRONG! Python is an interpreted language. Your source code is converted to bytecode internally, but that bytecode is then interpreted by the Python Virtual Machine (PVM), not converted into a stand-alone machine code file like in C/C++.

๐Ÿ“‹ Board Exam Tip

"Write any two advantages and two disadvantages of Python." โ€” 2-mark question, asked very often! Answer: Advantages: (i) Easy to use with simple syntax, (ii) Free and open source. Disadvantages: (i) Slower than compiled languages like C/C++, (ii) Not strong on type-binding.


4.5 โš™๏ธ How Python Executes a Program

Python uses an interpreter to run programs. Let's first understand the two types of language translators.

4.5.1 Compiler vs Interpreter ๐Ÿ”„

๐Ÿ“ฆ

Compiler

Translates the WHOLE program into machine code at once, then runs it

CC++
๐Ÿ”

Interpreter

Translates and executes the program LINE BY LINE

PythonJavaScript
Feature Compiler Interpreter
Translation Entire program at once One line (statement) at a time
Error Reporting Shows ALL errors together after compiling Stops at the FIRST error it finds
Execution Speed Faster (already translated) Slower (translates while running)
Debugging Harder Easier
Example C, C++ Python

Analogy: A Compiler is like a translator who translates an ENTIRE book into Hindi first and then hands it to you. An Interpreter is like a live translator standing next to a speaker โ€” translating each sentence as soon as it is spoken!

4.5.2 Inside the Python Interpreter ๐Ÿ”ฌ

When you run a Python program, it goes through these steps behind the scenes:

graph LR
    SRC["๐Ÿ“ Source Code\n(hello.py)"]
    COMP["โš™๏ธ Compiler\n(inside Python)"]
    BYTE["๐Ÿ“„ Bytecode\n(.pyc file)"]
    PVM["๐Ÿ–ฅ๏ธ PVM\n(Python Virtual\nMachine)"]
    OUT["๐Ÿ“ค Output"]

    SRC --> COMP --> BYTE --> PVM --> OUT

    style SRC fill:#2196F3,color:#fff
    style BYTE fill:#FF9800,color:#fff
    style PVM fill:#F44336,color:#fff
    style OUT fill:#4CAF50,color:#fff
  1. You write the source code in a file with the .py extension.
  2. Python internally compiles it into bytecode โ€” a low-level, platform-independent set of instructions (sometimes saved as .pyc files).
  3. The Python Virtual Machine (PVM) reads the bytecode and executes it line by line on your computer.
๐Ÿง  Why is Python Cross-Platform? ๐Ÿง 

Because bytecode is platform-independent! The same bytecode can run on ANY computer (Windows, Linux, macOS) that has a Python Virtual Machine installed. The PVM takes care of talking to the actual hardware.

๐Ÿ“‹ Board Exam Tip

"What is the difference between a compiler and an interpreter?" โ€” 2-mark question! Answer: A compiler translates the entire program into machine code at once and reports all errors together. An interpreter translates and executes the program line by line and stops as soon as it finds an error. Python uses an interpreter.


4.6 ๐Ÿ› ๏ธ Working in Python

To write and run Python programs, you need a Python interpreter installed on your computer (download it free from python.org). The standard installation comes with IDLE.

4.6.1 Python IDLE ๐Ÿ–ฅ๏ธ

IDLE stands for Integrated Development and Learning Environment. It is the default editor that comes with Python.

๐Ÿš

Python Shell

The window that shows the >>> prompt and executes commands immediately

Interactive Mode
๐Ÿ“

Editor Window

A text editor to write, save and run complete programs

Script Mode
๐ŸŽจ

Syntax Colouring

Keywords, strings and comments are shown in different colours

Easy to read code
๐Ÿž

Debugger

Helps find and fix errors step by step

Debug menu

Other popular Python tools (IDEs and distributions):

Tool What it is
Anaconda A free Python distribution with many data-science packages pre-installed
Jupyter Notebook A web-based tool to write code and see output in "cells"
Spyder An IDE that comes with Anaconda, popular for scientific work
PyCharm A professional IDE for Python
Visual Studio Code A popular free code editor with Python support
๐Ÿ’ก No Python on your computer?

You can still practise every program in these notes using the Python Lab on CSIP12 โ€” it runs Python right inside your browser! Just click the Run button on any code block.

Python code can be run in two modes:

graph TD
    MODES["๐Ÿ WORKING IN PYTHON"]
    INT["โšก Interactive Mode\n(Python Shell, >>> prompt)\nOne command at a time"]
    SCR["๐Ÿ“ Script Mode\n(.py file)\nWhole program at once"]

    MODES --> INT
    MODES --> SCR

    style INT fill:#FF9800,color:#fff
    style SCR fill:#2196F3,color:#fff

4.6.2 Interactive Mode โšก

In Interactive Mode, you type one command at a time at the Python prompt >>> (called the chevron or primary prompt), and Python executes it immediately and shows the result.

>>> 2 + 3
5
>>> 10 * 4
40
>>> print("Hello, Python!")
Hello, Python!
>>> 7 / 2
3.5

Analogy: Interactive Mode is like chatting with a friend on WhatsApp โ€” you send ONE message and get a reply INSTANTLY. But the chat isn't saved as a neat document you can hand in later!

๐Ÿ‘

Advantages

Instant result for each command; great for testing small pieces of code and using Python as a calculator

Quick testing
๐Ÿ‘Ž

Disadvantages

Commands CANNOT be saved for later use; you must retype everything; not suitable for long programs

Not saved

To leave the Python shell, type exit() or quit().


4.6.3 Script Mode ๐Ÿ“

In Script Mode, you write the complete program in a file, save it with the .py extension, and then run the whole file at once.

Steps to create and run a program in IDLE (Script Mode):

graph LR
    S1["1๏ธโƒฃ File โ†’ New File\n(opens Editor)"]
    S2["2๏ธโƒฃ Type the\nprogram"]
    S3["3๏ธโƒฃ File โ†’ Save\n(name.py)"]
    S4["4๏ธโƒฃ Run โ†’ Run Module\n(or press F5)"]
    S5["5๏ธโƒฃ Output appears\nin Python Shell"]

    S1 --> S2 --> S3 --> S4 --> S5

    style S1 fill:#9C27B0,color:#fff
    style S3 fill:#FF9800,color:#fff
    style S4 fill:#F44336,color:#fff
    style S5 fill:#4CAF50,color:#fff

Example โ€” save this as welcome.py:

# My first Python program
name = "Riya"
print("Hello,", name)
print("Welcome to Python programming!")

Output:

Hello, Riya
Welcome to Python programming!
๐Ÿ‘

Advantages

Program is SAVED permanently; can be edited and re-run any number of times; suitable for long programs

Reusable
๐Ÿ‘Ž

Disadvantages

Output is seen only after the whole program runs; slightly more steps to test a tiny command

Extra steps

Interactive Mode vs Script Mode โ€” The Critical Comparison:

Feature Interactive Mode Script Mode
How code is typed One statement at a time at the >>> prompt Whole program in the Editor window
Execution Each statement runs immediately Whole file runs when you press F5
Saving Code CANNOT be saved Code is saved as a .py file
Editing Previous commands can't be edited easily Program can be edited and re-run anytime
Best for Testing small code, quick calculations Writing complete, long programs
๐Ÿ“‹ Board Exam Tip

"Differentiate between Interactive Mode and Script Mode of Python." โ€” 2-mark question, asked almost EVERY year! Answer: In Interactive Mode, statements are typed one at a time at the >>> prompt and executed immediately, but the code cannot be saved. In Script Mode, the complete program is written in a file, saved with a .py extension, and can be executed and modified any number of times.


4.7 ๐Ÿ–จ๏ธ Understanding the print() Function

The print() function is used to display output on the screen. It is the very first function every Python programmer learns!

print("Hello, World!")        # prints text (a string)
print(25)                     # prints a number
print(10 + 5)                 # prints the RESULT of an expression
print("Sum =", 10 + 5)        # prints text and a value together

Output:

Hello, World!
25
15
Sum = 15
๐Ÿ”ค

Text (String)

Must be enclosed in single or double quotes

'Hi'"Hi"
๐Ÿ”ข

Numbers

Written without quotes

253.14
โž•

Expressions

Python calculates first, then prints the result

10 + 5 โ†’ 15
๐Ÿ”—

Multiple Items

Separated by commas; printed with a space in between

Comma separated
โš  Common Mistake

print("10 + 5") prints 10 + 5 (it's text inside quotes!), whereas print(10 + 5) prints 15. Anything inside quotes is printed exactly as it is.

โš  Python is Case-Sensitive!

print and Print are NOT the same. Writing Print("Hi") gives an error: NameError: name 'Print' is not defined.

Comments โ€” lines starting with # are comments. Python ignores them; they are written to explain the code to humans.

# This whole line is a comment
print("Python is fun!")   # this is an inline comment
๐Ÿ”‘ Rule

Every Python statement at the top level must start at the beginning of the line (no extra spaces before it). An unexpected space at the start gives an IndentationError. You'll learn more about indentation in the Python Fundamentals chapter.


โš ๏ธ Common Errors and Misconceptions

Mistake What's Wrong Correct Understanding
โŒ Python is named after the snake It's a popular myth โœ… Named after the comedy show "Monty Python's Flying Circus"
โŒ Python is a compiled language Python does not produce a stand-alone machine code file โœ… Python is an interpreted language (source โ†’ bytecode โ†’ PVM)
โŒ Code typed in Interactive Mode is saved automatically The shell doesn't save your commands โœ… Use Script Mode (.py file) to save programs
โŒ Python files are saved with .pyt or .pt extension Wrong extension โœ… Python source files use the .py extension
โŒ Print() and print() are the same Python is case-sensitive โœ… Only print() (all lowercase) is correct
โŒ print("5 + 3") will print 8 Text in quotes is printed as it is โœ… It prints 5 + 3; use print(5 + 3) to get 8
โŒ IDLE stands for "Integrated Development Language Editor" Wrong full form โœ… IDLE = Integrated Development and Learning Environment

๐Ÿ”‘ Quick Revision โ€” Exam Ready!

Python โ€” One-Line Facts:

  • Developer โ†’ Guido van Rossum (Netherlands)
  • Released โ†’ 1991
  • Based on โ†’ ABC and Modula-3
  • Named after โ†’ Monty Python's Flying Circus
  • Type โ†’ High-level, interpreted, object-oriented, general-purpose
  • File extension โ†’ .py
  • Default editor โ†’ IDLE (Integrated Development and Learning Environment)

Pluses vs Minuses:

โœ… Pluses โŒ Minuses
Easy to use Not the fastest language
Expressive language Not strong on type-binding
Interpreted language Not easily convertible
Completeness (big standard library) Lesser libraries in some areas (e.g., mobile apps)
Cross-platform
Free & open source
Variety of usage

Execution Flow:

  • Source code (.py) โ†’ Bytecode (.pyc) โ†’ PVM โ†’ Output

Two Modes:

Interactive Mode Script Mode
Prompt / Window >>> Python Shell Editor window
Saved? No Yes (.py)
Run Immediately, per statement Whole file (F5)

๐ŸŽฏ Sample Board Exam Questions

Q1: Very Short Answer [1 mark each]

a) Who developed Python? โ†’ Guido van Rossum

b) In which year was Python first released? โ†’ 1991

c) What is the extension of a Python source file? โ†’ .py

d) What is the full form of IDLE? โ†’ Integrated Development and Learning Environment

e) What does the >>> symbol in the Python shell indicate? โ†’ It is the Python prompt (chevron), showing that Python is ready to accept a command in Interactive Mode

f) Name the two languages on which Python is based. โ†’ ABC and Modula-3


Q2: Short Answer [2 marks]

Q: Differentiate between Interactive Mode and Script Mode.

In Interactive Mode, the user types one statement at a time at the >>> prompt and Python executes it immediately; the commands cannot be saved for future use. In Script Mode, the complete program is typed in an editor, saved as a .py file, and executed as a whole; it can be edited and re-run any number of times.


Q3: Short Answer [2 marks]

Q: Write any two advantages and two limitations of Python.

Advantages: (i) Python is easy to use with simple, English-like syntax. (ii) Python is free and open source, and it is cross-platform. Limitations: (i) Python is slower than compiled languages like C/C++. (ii) Python is not strong on type-binding โ€” some type-related errors are found only while the program runs.


Q4: Short Answer [2 marks]

Q: Why is Python called an interpreted language? Explain briefly how a Python program is executed.

Python is called an interpreted language because its programs are executed line by line by the Python interpreter, rather than being fully translated into machine code beforehand. The source code (.py) is first converted into bytecode, which is then executed by the Python Virtual Machine (PVM) to produce the output.


Q5: Output Based [2 marks]

Q: Write the output of the following code:

print("5 + 3")
print(5 + 3)
print("Total =", 5 * 3)

Answer:

5 + 3
8
Total = 15

โœ๏ธ Practice Problems

  1. What is a programming language? Differentiate between low-level and high-level languages with one example each.

  2. Explain any four features (pluses) of Python.

  3. What is meant by "Python is a cross-platform language"? How does bytecode make this possible?

  4. Differentiate between a compiler and an interpreter. Which one does Python use?

  5. Write the steps to create, save and run a Python program in IDLE.

  6. Use Python in Interactive Mode as a calculator to find: (a) 125 ร— 8 (b) 256 รท 16 (c) 15 + 27 โˆ’ 9. Write the commands you typed and the results shown.

  7. Write a program in Script Mode that prints your name, class and school name on three separate lines.

  8. Find the error(s) in the following code and rewrite it correctly:

    Print("Hello World")
    print(Welcome to Python)
  9. A friend says, "I typed a long program in the Python shell, and now I want to run it again tomorrow." What problem will your friend face? Suggest the correct approach.

  10. List any three areas where Python is used today, with one example of a library or tool for each.

Learning Support

Need Help With This Chapter?

Save key topics for exam revision, ask questions to teachers, or submit content corrections.

Verified Doubts & Teacher Answers

Take the Chapter 04 Quiz