Free tutorials & notes in Hindi & English · Clean code examples 🧰 Free PDF & Image Tools →
🐍 Unit 2 – Python Basics  ·  Lesson 11

Getting Started with Python

What is Python?

Python is a popular, free, high-level programming language created by Guido van Rossum (released in 1991). Its code looks almost like English, so it is the first language taught in CBSE Classes XI and XII. YouTube, Instagram, NASA and most AI tools use Python.

Same task in C++

  • #include <iostream>
  • int main() {
  •   std::cout << "Hello";
  •   return 0; }

Same task in Python

  • print("Hello")
  • One line – no main, no semicolons, no brackets
Python is short and readable

Features of Python

📖
Easy to readSimple English-like syntax; uses indentation instead of { }.
🆓
Free & open sourceDownload free from python.org; anyone can improve it.
🧑‍💻
InterpretedRuns line by line, so errors are easy to locate.
💻
PortableSame program runs on Windows, Linux, macOS.
📚
Huge libraryReady modules for maths, data, web, games, AI.
🔤
Case-sensitiveMarks, marks and MARKS are three different names.
Why Python?

Installing Python and IDLE

  1. 1Open python.org/downloads and download the latest Python 3 for your computer.
  2. 2Run the installer. On Windows, tick "Add python.exe to PATH", then click Install Now.
  3. 3Open IDLE (Integrated Development and Learning Environment) from the Start menu.
  4. 4You will see the Python shell with the prompt >>>. Python is ready!
Install Python in four steps

You can also use editors like VS Code, Thonny, PyCharm, or online tools like Google Colab and Jupyter Notebook.

Interactive mode vs script mode

Interactive mode (shell)

  • Type a statement after >>> and press Enter
  • Result appears immediately
  • Great for testing small things
  • Code is not saved

Script mode (file)

  • Write the full program in a file with .py extension
  • IDLE: File → New File, then Run → Run Module (F5)
  • Program can be saved, edited and run again
  • Used for all real programs
Two ways to run Python
Python shell
>>> 5 + 3
8
>>> 'Hi' * 3
'HiHiHi'
>>> 22 / 7
3.142857142857143

Your first program

In IDLE choose File → New File, type the lines below, save as hello.py and press F5.

Python
print('Hello, Class XI!')
print('My first Python program')
print(25 + 17)
Hello, Class XI! My first Python program 42

print() is a built-in function that shows output on the screen. Text must be inside quotes (single '…' or double "…"); numbers and calculations do not need quotes.

More about print()

print() can show many values separated by commas. Two useful options: sep (what to put between values, default a space) and end (what to put at the end, default a new line).

Python
print('Mango', 'Apple', 'Banana')            # sep is a space by default
print('Mango', 'Apple', 'Banana', sep=' | ')
print('Loading', end='...')
print('done')
print()                                      # empty line
print('Rs.', 250 * 3)
Mango Apple Banana Mango | Apple | Banana Loading...done Rs. 750

Comments

A comment is a note for humans; Python ignores it. A single-line comment starts with #. For longer notes you can use a string in triple quotes '''…''' (called a docstring when it describes a function).

Python
# This program finds the area of a circle
radius = 7          # radius in cm
area = 3.14 * radius * radius
print('Area =', area, 'sq cm')
Area = 153.86 sq cm
💡 Good habit

Write comments that explain why, not just what. "# 3.14 used as value of pi" helps a reader more than "# multiply".

Keywords

Keywords are reserved words with a special meaning in Python, such as if, for, while, def, True. You cannot use them as variable names.

Python
import keyword
print(len(keyword.kwlist), 'keywords')
print(keyword.kwlist[:10])
print(keyword.iskeyword('for'), keyword.iskeyword('marks'))
35 keywords ['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class'] True False
All 35 keywords (Python 3.7+)
FalseNoneTrueandasassertasync
awaitbreakclasscontinuedefdelelif
elseexceptfinallyforfromglobalif
importinislambdanonlocalnotor
passraisereturntrywhilewithyield

Identifiers and naming rules

An identifier is the name we give to a variable, function or class. Rules:

  1. Can contain letters (a–z, A–Z), digits (0–9) and underscore _.
  2. Must not start with a digit.
  3. Cannot be a keyword.
  4. No spaces or special symbols like @ $ % - !.
  5. Case-sensitive: Total and total are different.

Valid ✔

  • marks
  • total_marks
  • _count
  • student2
  • RollNo

Invalid ✘

  • 2nd_name – starts with digit
  • total marks – has a space
  • for – keyword
  • price$ – special symbol
  • my-name – hyphen means minus
Check before you name
Python
2nd_name = 'Riya'
SyntaxError: invalid decimal literal

Use meaningful names: percentage is far better than p when someone else reads your program.

Summary & practice

  • Python: easy, free, interpreted, portable, case-sensitive.
  • Interactive mode for quick tests; script mode (.py file) for programs.
  • print() with sep and end; comments start with #.
  • 35 keywords; identifiers cannot start with a digit or be a keyword.
✅ Practice

Which are valid identifiers? Class, class, _9marks, roll-no, none, None. Then write one print statement that outputs 2026-27 using the numbers 2026 and 27 with sep.

Answers: valid: Class, _9marks, none; invalid: class, None (keywords), roll-no (hyphen). print(2026, 27, sep='-')

Frequently Asked Questions

Who created Python?
Guido van Rossum created Python and released it in 1991. It is named after the comedy show "Monty Python’s Flying Circus", not the snake.
How many keywords are there in Python?
Python 3.7 and newer have 35 keywords. You can see them with import keyword; print(keyword.kwlist). True, False and None start with a capital letter.
Can an identifier start with a digit?
No. An identifier must start with a letter or underscore. It can contain digits after the first character, like marks2 or _total.
← Class 11 Computer Science
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

Next topicVariables, Data Types & Mutability Your progress: 11 / 29 (38%) · Lesson 12 / 29 Continue →

How was this lesson?

Your feedback helps us make the content better.

Write a review or suggestion (optional)

After approval, your name and city may appear publicly with your review. Please do not write your email or phone number.

▶ CodingEasily on YouTube

Learn with video lessons in easy Hindi

Featured video: RDBMS Part 3 – Class XI Commerce IT

▶ Subscribe – it’s free