0% found this document useful (0 votes)
3 views17 pages

Grade8 IT Chapter2 Python

This document serves as a self-study guide for beginners learning Python in Class 8 I.T. It covers fundamental concepts such as programming languages, Python features, commands, keywords, syntax, data types, and common mistakes. The guide emphasizes Python's simplicity and readability, making it an ideal first programming language.

Uploaded by

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

Grade8 IT Chapter2 Python

This document serves as a self-study guide for beginners learning Python in Class 8 I.T. It covers fundamental concepts such as programming languages, Python features, commands, keywords, syntax, data types, and common mistakes. The guide emphasizes Python's simplicity and readability, making it an ideal first programming language.

Uploaded by

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

INFORMATION TECHNOLOGY

Chapter 2

Python
Simple, Self-Study Notes for Complete Beginners

Class 8 • CBSE Subject: I.T.

Your first text language!

Read • Try • Learn — one small step at a time ★


◆ What you will learn in this chapter
1. Programming languages 7. Arithmetic operators
2. What is Python 8. Values & Variables
3. Features of Python 9. Naming rules & Comments
4. Commands & Keywords 10. Data types (full)
5. Syntax & Indentation 11. Revision & Exam tips
6. Statements & Expressions

1 Introduction

What is a programming language?


People talk to each other using languages like English, Hindi or Tamil. In the same way, we talk to a computer
using a special language. A programming language is a language that a computer can understand. We use
it to give the computer instructions.

Why do we need programming languages?


A computer does not understand human languages directly. We need a clear, fixed language with simple rules
so the computer never gets confused. Programming languages let us write instructions that the computer can
follow exactly — to do maths, show messages, play games and much more.

● Easy idea
A programming language is a bridge between you and the computer. You write on one side, the
computer understands on the other side.

Introducing Python
There are many programming languages. One of the easiest and most popular is Python. It is a great first
language because its words look almost like simple English.

2 Python Is…

● Definition
Python is a simple, popular programming language used to write instructions for a computer. It was
created by Guido van Rossum and is known for being very easy to read and write.

Why students learn Python


✓ Its commands look like normal English, so it is easy to understand.

Grade 8 Information Technology • Self-Study Notes Page 2


✓ You can write programs in fewer lines than many other languages.

✓ It is free and used by real companies, scientists and game makers.

✓ It is a perfect first step before learning harder languages.

● Real-life connection
Learning Python is like learning to ride a bicycle before a motorbike. It is friendly and forgiving, and once
you learn it, many other things become easy.

3 Features of Python

A “feature” is a good quality of something. Here are Python’s best features, one by one.

5 Friendly Features of Python

Easy to Simple Free to Used in


Powerful
learn syntax use many fields

Infographic: the five key features of Python.

Feature What it means (simple) Example

Words are close to English, so beginners pick it up print("Hello") shows


Easy to learn
fast Hello

Simple syntax The rules of writing are short and neat No need for many symbols

Free to use Anyone can download and use it without paying Download from [Link]

Powerful Can do small and very big jobs Maths, games, websites

Used in many
Used in science, AI, apps, and more Robots, data, animation
fields

Grade 8 Information Technology • Self-Study Notes Page 3


4 Python Commands

● Definition
A command is an instruction that tells the computer to do one job. When you give a command, the
computer does exactly that one thing.

The most common beginner command is print. It tells Python to show something on the screen.

P Y T H O N — B E G I N N E R C O M M A N D S print("Hello, world!") print("My name is Sam") print(5 + 3)


Output: Hello, world! My name is Sam 8

● Easy idea
A command is like pressing one button on a remote: “show this”, “add these”. Each press (command)
does one job.

5 Python Keywords

● Definition
Keywords are special words that already have a fixed meaning in Python. We cannot use them for our
own names because Python has reserved them for special jobs.

Keyword What it is used for

if To check a condition (make a decision)

else What to do when the if is not true

for To repeat steps a fixed number of times (a loop)

while To repeat steps as long as a condition is true (a loop)

True Means “yes / correct”

False Means “no / not correct”

● Common mistake
You cannot name a variable if or for. These are keywords. Choose a different name like score or count.

Grade 8 Information Technology • Self-Study Notes Page 4


6 Python Syntax

● Definition
Syntax means the rules for writing code correctly — the right words, in the right order, with the right
symbols.

● Helpful analogy
Syntax is like the grammar rules of a language. In English we write “I am happy”, not “Happy am I be”. If
grammar is wrong, the sentence is confusing. If Python syntax is wrong, the computer shows an error and
stops.

Correct syntax Wrong syntax

print("Hi") print "Hi"

Brackets and quotes are correct. Missing brackets → Python shows an error.

7 Spaces and Indentation in Python

● Definition
Indentation means the empty space left at the start of a line (usually 4 spaces). In Python, this spacing
is not just for looks — it tells Python which lines belong together.

Most languages use brackets to group lines. Python uses indentation instead. So spacing is very important —
wrong spacing gives an error.

Correct indentation Wrong indentation

if score > 90: print("Great!") if score > 90: print("Great!")

The print line is pushed in by 4 spaces. No space → Python gets confused → error.

● Remember
After a line ending with : (colon), the next lines must be indented (pushed in). Use 4 spaces every time.

Grade 8 Information Technology • Self-Study Notes Page 5


8 Statements

● Definition
A statement is one complete instruction that does something. Usually one line of code is one statement.

E A C H L I N E I S A S T A T E M E N T name = "Sam" # a statement age = 12 # a statement print(name) # a


statement

9 Expressions

● Definition
An expression is a piece of code that gives a value when calculated. For example, 5 + 3 is an
expression because it produces the value 8.

Difference between statement and expression

Statement Expression

Meaning An instruction that does something A calculation that gives a value

Example x = 10 5 + 3

Result Stores 10 in x Gives 8

● Tip
An expression often sits inside a statement. In x = 5 + 3, the whole line is a statement, and 5 + 3 is the
expression inside it.

Grade 8 Information Technology • Self-Study Notes Page 6


10 Arithmetic Operators in Python

● Definition
Arithmetic operators are symbols that do maths — like add, subtract, multiply and divide.

Operator Meaning Example Answer

+ Addition 5 + 3 8

- Subtraction 9 - 4 5

* Multiplication 6 * 2 12

/ Division 10 / 2 5.0

% Modulus (remainder left over) 10 % 3 1

** Power (exponent) 2 ** 3 8

● Remember
% gives the remainder. 10 % 3 = 1 because 3 goes into 10 three times (9) and 1 is left over. ** means
power: 2 ** 3 = 2 × 2 × 2 = 8.

11 Values and Variables

What is a value?
A value is a piece of data that the program works with — like a number or some text. Numbers like 10 and
words like "Hello" are values.

Number values vs String values

Number value String value

What it is A number used for counting and maths Text — letters, words or sentences

Quotes? No quotes Always inside quotes " "

Examples 10, 25 "Hello", "Sam"

Can do maths? Yes (5 + 3 = 8) No (it is just text)

Grade 8 Information Technology • Self-Study Notes Page 7


● Common mistake
"10" with quotes is a string (text), not a number. "10" + "5" gives "105" (joined text), not 15!

12 Variables

Meaning and purpose


A variable is a name used to store a value. We use variables so the program can remember information
and use it again later.

● Analogy
A variable is a labelled box. The label is the name; the value is what you put inside. age = 12 means the
box labelled age holds the value 12.

"Sam" 12
name = "Sam" age = 12

Block diagram: the variable name is the label, the value is inside the box.

Creating variables (step by step)


To create a variable: write the name, then =, then the value.

CREATING VARIABLES# name = value name = "Sam" age = 12 print(name) print(age) Output: Sam
12

● Another way to say it


A variable is simply a name used to store a value. The same idea, in shorter words.

Python variable naming rules


✓ A name must start with a letter (or underscore _), not a number.

✓ It can not have spaces (use my_age, not my age).

✓ You cannot use keywords like if or for as names.

Grade 8 Information Technology • Self-Study Notes Page 8


✓ Use meaningful names so the code is easy to read (score is better than x).

Good names Bad names Why bad

age 2age Starts with a number

my_score my score Has a space

total for It is a keyword

Comments in Python

● Definition
A comment is a note for humans inside the code. Python ignores comments — they do not run. We use
them to explain what the code does.

Single-line comment
Starts with a #. Everything after # on that line is a comment.

# This is a single-line comment print("Hi") # this part is also a comment

Multi-line comment
For a comment over many lines, we use three quotes """ at the start and end.

""" This is a multi-line comment. It spans many lines. """ print("Done")

Grade 8 Information Technology • Self-Study Notes Page 9


13 Data Types

● Definition
A data type tells us what kind of data a value is — for example a number, some text, or a true/false
answer.

What does “type” mean?


“Type” means the kind of something. In Python, the type tells us what kind of value we have, so Python knows
how to use it.

Value Type

10 Number

"Hello" Text (string)

True Boolean (yes/no)

Type conversion
Type conversion means changing a value from one type into another. For example, changing the text "10"
into the number 10.

CHANGING TYPESx = "10" # text y = int(x) # now a number 10 print(y + 5) # works! gives 15
Output: 15

Data Types in Python

Data Types

Numeric String Boolean Set Mapping Sequence

int, float, "text" True / False {1, 2, 3} dictionary list, tuple


complex

Concept map: the main data types in Python and their examples.

Grade 8 Information Technology • Self-Study Notes Page 10


A. Numeric types

1. Integer (int)
Whole numbers, with no decimal point. Can be positive or negative.

marks = 95 year = 2026 temperature = -3

2. Float
Numbers with a decimal point.

height = 1.65 price = 49.99

3. Complex (just an introduction)


Sometimes maths uses special numbers called complex numbers, written with a j, like 3 + 4j. You do not
need to use these now — just know that Python can handle them when you study higher maths.

B. String
A string is text — letters, words or sentences inside quotes " ".

name = "Rahul" city = "Delhi"

Useful string methods

Method What it does Example Result

upper() Makes all letters CAPITAL "hi".upper() "HI"

lower() Makes all letters small "HI".lower() "hi"

len() Counts the letters (length) len("cat") 3

C. Boolean
A Boolean value can be only one of two things: True or False. It answers yes/no questions.

is_raining = True passed = False print(10 > 5) # is 10 bigger than 5? Output: True

D. Set
A set is a collection of items with no repeats, written inside curly brackets { }. The order does not matter.

fruits = {"apple", "banana", "mango"}

Grade 8 Information Technology • Self-Study Notes Page 11


● Tip
If you put the same item twice in a set, Python keeps only one copy. Sets remove duplicates automatically.

E. Mapping (Dictionary)
A mapping stores data in pairs: a key and its value. In Python this is called a dictionary, written with { }.

student = { "Name": "Rahul", "Age": 13 }

Key Value

Name Rahul

Age 13

● Real-life connection
A dictionary is like a school register: each name (key) points to a detail (value), such as roll number or
age.

F. Sequence
A sequence stores many items in a fixed order. The two main sequence types are list and tuple.

List
A list is an ordered collection inside square brackets [ ]. You can change a list (add or remove items).

marks = [80, 90, 75] colours = ["red", "blue"]

Tuple
A tuple is also an ordered collection, but inside round brackets ( ), and it cannot be changed after it is made.

point = (4, 5) days = ("Mon", "Tue")

Dictionary (a quick recall)


As seen above, a dictionary stores key–value pairs with { }. It is sometimes grouped here because it also holds
many items.

student = {"Name": "Rahul", "Age": 13}

Grade 8 Information Technology • Self-Study Notes Page 12


Type Brackets Can change? Example

List [ ] square Yes [80, 90, 75]

Tuple ( ) round No (4, 5)

Dictionary { } curly Yes {"Age": 13}

Set { } curly Yes (no repeats) {1, 2, 3}

Grade 8 Information Technology • Self-Study Notes Page 13


★ Final Revision — Python

Important definitions

Word Simple meaning

Programming language A language the computer understands

Python An easy, popular programming language

Command An instruction to do one job

Keyword A special reserved word with a fixed meaning

Syntax The grammar/rules of writing code

Indentation Spaces at the start of a line that group code

Statement One complete instruction

Expression Code that gives a value

Variable A name that stores a value

Data type The kind of data a value is

Important keywords
if, else, for, while, True, False, int, print

Quick revision notes


✓ Python words look like English — easy for beginners.

✓ print() shows things on the screen.

✓ Strings need quotes; numbers do not.

✓ Indent (4 spaces) after a line ending with :.

✓ Operators: + - * / % **.

✓ Data types: int, float, complex, string, boolean, set, dictionary, list, tuple.

● Memory tricks
“Strings wear quotes, numbers go bare.” • List = Lots (square [ ], can change). • Tuple = Tied
up (round ( ), cannot change). • % = what is left over.

Grade 8 Information Technology • Self-Study Notes Page 14


● Common mistakes students make
• Forgetting the brackets in print( ).
• Forgetting quotes around strings.
• Wrong indentation after a colon :.
• Using a keyword (like for) as a variable name.
• Thinking "10" (text) is the same as 10 (number).

● Exam tips
• Learn each definition in one simple line.
• Remember example outputs (e.g. 2 ** 3 = 8).
• Practise spotting correct vs wrong syntax.
• Draw the data-types concept map from memory.

Q Python — Practice Questions

A. Multiple Choice Questions


1. A language a computer understands is a ____. (a) programming language (b) song (c) story (d) drawing)

2. Which command shows text on screen? (a) show (b) print (c) tell (d) say)

3. Which is a keyword? (a) score (b) if (c) name (d) total)

4. Syntax means the ____ of writing code. (a) colour (b) rules (c) speed (d) sound)

5. Indentation means ____ at the start of a line. (a) numbers (b) spaces (c) colours (d) sounds)

6. 5 + 3 is an ____. (a) expression (b) keyword (c) comment (d) error)

7. Which operator gives the remainder? (a) + (b) * (c) % (d) /)

8. 2 ** 3 equals ____. (a) 6 (b) 8 (c) 5 (d) 23)

9. A whole number type is ____. (a) float (b) int (c) string (d) set)

10. A decimal number type is ____. (a) int (b) float (c) bool (d) list)

11. True and False are ____ values. (a) Boolean (b) string (c) float (d) list)

12. A list uses ____ brackets. (a) round (b) curly (c) square (d) angle)

13. A tuple uses ____ brackets. (a) round (b) curly (c) square (d) angle)

14. A dictionary stores ____. (a) only numbers (b) key–value pairs (c) only text (d) nothing)

15. A comment starts with ____. (a) ! (b) # (c) @ (d) &)

B. Fill in the Blanks


1. Python was created by Guido van ____.

2. The ____ command displays output.

Grade 8 Information Technology • Self-Study Notes Page 15


3. Strings are always written inside ____.

4. The rules for writing code are called ____.

5. After a colon, the next line must be ____.

6. A name that stores a value is a ____.

7. The % operator gives the ____.

8. len("cat") gives ____.

9. A set cannot have ____ items.

10. A tuple cannot be ____ after it is made.

C. True or False
1. Python is hard to read. ( )

2. Numbers are written inside quotes. ( )

3. Indentation is important in Python. ( )

4. A keyword can be used as a variable name. ( )

5. A list can be changed. ( )

6. A tuple can be changed. ( )

7. upper() makes letters capital. ( )

8. Comments are run by Python. ( )

D. Match the Following

Column A Column B

1. int a. Text in quotes

2. string b. True / False

3. Boolean c. Whole number

4. list d. Key–value pairs

5. dictionary e. Ordered, square brackets

E. Very Short Answers


1. What is Python?

2. What does print() do?

3. What is a keyword?

4. What is a variable?

5. What is indentation?

F. Short Answers
1. Write any three features of Python.

Grade 8 Information Technology • Self-Study Notes Page 16


2. What is the difference between a statement and an expression?

3. Explain the difference between a list and a tuple.

4. Write the rules for naming a variable.

5. What are comments? Give one example.

G. Application-Based Questions
1. Write Python code to store your name and age in variables and print them.

2. What will 10 % 3 and 2 ** 4 give? Explain.

3. Make a dictionary that stores a student’s Name and Class.

4. A friend wrote print "Hi" and got an error. Fix it and explain why.

5. Change the text "25" into a number and add 5 to it. Write the code.

Grade 8 Information Technology • Self-Study Notes Page 17

You might also like