0% found this document useful (0 votes)
5 views3 pages

Programming An Introduction

The document provides an introduction to programming, defining key concepts such as programming languages, compilers, and interpreters, with a focus on Python. It highlights the importance of programming for creating software, websites, and solving problems, and outlines Python's features, usage, and basic data types. Additionally, it includes practical guidance on using Python's IDLE environment, variable naming rules, common functions, and error handling.

Uploaded by

pranshu.tps2025
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Programming An Introduction

The document provides an introduction to programming, defining key concepts such as programming languages, compilers, and interpreters, with a focus on Python. It highlights the importance of programming for creating software, websites, and solving problems, and outlines Python's features, usage, and basic data types. Additionally, it includes practical guidance on using Python's IDLE environment, variable naming rules, common functions, and error handling.

Uploaded by

pranshu.tps2025
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Programming An Introduction

Language:-A medium of communication is known as Language


Or
A language in computer science is a set of rules and symbols used to communicate instructions to a computer.
Program:- A sets of instructions called the programs

Programming:- Programming is the act of creating a set of instructions (code) that tells a computer what to do.

Why programming is important


 To create software and apps
 To make websites
 To solve mathematical problems
 To control machines and robots

Compiler:- A compiler is a program that translates the entire source code at once into machine language
before execution.
Example: -
 C, C++
 Errors are shown after compilation.
Interpreter:- An interpreter is a program that translates and executes code line by line.
Example: -
 Python, JavaScript
 Errors are shown line by line.

IDLE :- IDLE (Integrated Development and Learning Environment) is a software used to write, edit, and run Python
programs. Example:-
 It provides an editor, output window, and debugging tools.
 Python IDLE is commonly used by beginners.

Programming Language:- A programming language is a set of rules and symbols used to write instructions for
a computer to perform tasks. Example:- Python, C, Java

Machine Language:- Machine language is the language directly understood by the computer, written in binary form
(0s and 1s).Example:- It is very fast but difficult for humans to understand.

High Level Language:- A high level language is a programming language that is easy to read, write, and understand
by humans. Example: Python, Java, C++

Low Level Language:- low level language is a language that is close to machine language and difficult for humans
to understand. Example: Assembly language, Machine language
PYTHON:-
Python is one of the most popular programming languages in the world today (used by Google, NASA, Instagram,
YouTube, AI companies, etc.).
 Easy to read – looks almost like English
 Very beginner-friendly
 Used for: Games, websites, mobile apps, robots, data science, artificial intelligence, automation,
scientific calculations
 Fun fact: Python was named after Monty Python comedy show (not the snake!)

2. Who Created Python & When?


 Created by Guido van Rossum (Dutch programmer)
 First released in 1991
 Guido worked at Centrum Wiskunde & Informatica (CWI), Netherlands
 As of January 2026: Latest stable version is Python 3.14 (released October 2025). Python 3.15 is in
pre-release/alpha stage.

3. Key Features of Python (Make students repeat these!)


 High-level language (far from machine language)
 Interpreted (runs line-by-line – easier to find mistakes)
 Platform independent (same code runs on Windows, Mac, Linux)
 Simple & readable syntax (less curly braces & semicolons)
 Case-sensitive (Age ≠ age)
 Free & open-source
 Huge community & libraries

4. How Computer Works – Analogy (Very Important!)

Use the textbook pasta recipe analogy – it’s excellent!


Input → Process → Output
Stage Pasta Example Computer Example
Input Ingredients (water, pasta…) Data we give (numbers, name…)
Process Boiling, stirring, simmering Computer calculations & instructions
Output Ready tomato pasta Result on screen (sum, message…)

5. Two Ways to Use Python (IDLE)

Mode When to use? How it works Good for…


Type → Enter → See result immediately (>>> Experiments, learning
Interactive Testing small ideas quickly
prompt) basics
Writing longer, reusable
Script / File Write whole program → Save as .py → Run (F5) Real projects, homework
programs

Steps for Interactive Mode:


1. Start → All Programs → Python 3.14 → IDLE
2. See >>> prompt
3. Type: print("Hello Students!") → Enter

Steps for Script Mode:


1. File → New File
2. Write code
3. File → Save As → [Link] (example: [Link])
4. Run → Run Module (or press F5)

6. Important Parts of IDLE Window

 Title Bar → Name of file / Python version


 Menu Bar → File (New, Open, Save), Edit, Run, Help (F1 for help!)
 >>> Prompt → Only in interactive mode
 Status Bar → Shows cursor position, version info

7. Rules for Variable Names (Very Common Exam Question!)


Variable = named box to store data

Valid rules:

 Start with letter (A–Z, a–z) or underscore _


 Can have letters, digits (0–9), underscore
 Case-sensitive (marks ≠ Marks)
 No spaces, no special characters (@, #, $, etc.)
 Cannot be Python keyword (if, else, print, for, class…)

Examples
Valid Invalid Why Invalid?
student_age student age Space not allowed
total_marks2025 2025marks Starts with number
_price price@shop Special character
MyClass else Keyword
Common student mistake: Writing my name = "Rahul" → error (use my_name or myName)

8. Basic Data Types in Python (Table for Blackboard)

Type Full Name Stores what? Examples Function to convert


int Integer Whole numbers 5, -42, 0, 1000 int()
float Floating point Decimal numbers 3.14, -0.5, 7.0 float()
str String Text / characters "Hello", 'Agra', "123" str()
bool Boolean True / False (logic) True, False bool()

important: input() always gives string → convert before math!

9. input() and print() – Most Used Functions


input() → Ask user for value
name = input("What is your name? ")
age = int(input("Your age? ")) # convert to number!

print() → Show on screen


print("Hello", name)
print("You are", age, "years old")

Escape sequences (teach with examples):


Code Meaning Example code Output
\n New line print("Line1\nLine2") Line1 Line2
\t Tab space print("Name:\tRahul") Name: Rahul
Comma in print() → adds space automatically
print(a, b, c) # 10 20 30
print(a, "\t", b) # 10 20
0. Common Errors & How to Fix (Show These!)

 NameError: variable not defined → forgot to assign value


 TypeError: can't add string + number → use int() or float() Example: a = input() → a + 5 → error → fix: int(a) +
5
 Forgetting quotes around text → print(Hello) → error

11. Practice Questions for Students (From Book + More)

1. Print your school name, address, principal name in 5 lines using \n.
2. Take two numbers from user and print their sum.
3. Take length & breadth → print area & perimeter of rectangle.
4. Convert temperature: Fahrenheit to Celsius → C = (F - 32) × 5/9
5. Take student name, class, marks → print nicely formatted report.

You might also like