0% found this document useful (0 votes)
2 views4 pages

Formatted Python Notes Grade9

This document provides an overview of basic Python programming concepts for Grade 9, including output, user input, variables, type casting, math and comparison operators, selection statements, logical operators, loops, lists, and comments. Each section includes examples to illustrate the concepts. It serves as a foundational guide for beginners learning Python.

Uploaded by

jchounde0210
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)
2 views4 pages

Formatted Python Notes Grade9

This document provides an overview of basic Python programming concepts for Grade 9, including output, user input, variables, type casting, math and comparison operators, selection statements, logical operators, loops, lists, and comments. Each section includes examples to illustrate the concepts. It serves as a foundational guide for beginners learning Python.

Uploaded by

jchounde0210
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

PYTHON NOTES – GRADE 9 (CAMBRIDGE)

1. Basic Output

The print() function displays text or results on the screen.


Example:
print("Hello World")
print(5 + 3)

2. Input from the User

The input() function takes text from the keyboard. It stores the input as a string unless converted.
Example:
name = input("Enter your name: ")
print("Hello", name)

3. Variables

Variables store data values.


age = 15
score = 88.5
name = "Jivika"

4. Type Casting (Changing Data Types)

Used to convert input to numbers when needed.


age = int(input("Enter your age: "))
height = float(input("Enter your height: "))

5. Math Operators

Operator Meaning
+ Addition
- Subtraction
* Multiplication
/ Division (float)
% Remainder
// Floor divide
** Exponent / Power
Example:
print(5 ** 2) # 25
print(10 % 3) # 1
print(7 // 2) # 3

5.1 Comparison Operators

Operator Meaning Example Result


== Equal to 5 == 5 True
!= Not equal to 5 != 3 True
> Greater than 7>4 True
< Less than 2<9 True
>= Greater or equal 8 >= 8 True
<= Less or equal 3 <= 5 True

Example in IF:
if age >= 18:
print("Adult")
else:
print("Not Adult")

6. Selection (IF Statements)

Used for decision making.


IF Example:
if score > 50:
print('Pass')
IF–ELSE Example:
if score >= 50:
print('Pass')
else:
print('Fail')
IF–ELIF–ELSE Example:
if marks >= 90:
print('A')
elif marks >= 70:
print('B')
else:
print('C')

7. Logical Operators

Operator Meaning
and Both conditions true
or At least one condition true
not Reverses the condition

Example:
if age > 12 and age < 20:
print('Teenager')

8. Loops

FOR Loop: Used when number of repetitions is known.


for i in range(5):
print(i)
Output:
0
1
2
3
4
WHILE Loop:
x=1
while x <= 3:
print(x)
x=x+1
Output:
1
2
3

9. Lists

Lists store multiple values.


Creating a List:
fruits = ['apple','banana','mango']
Output:
['apple','banana','mango']
Accessing Items:
fruits[0] → apple
fruits[1] → banana
Adding Items:
[Link]('orange')
Output:
['apple','banana','mango','orange']
Removing Items:
[Link]('banana')
Output:
['apple','mango','orange']
Looping Through a List:
for item in fruits:
print(item)
Output:
apple
mango
orange
Length of a List:
len(fruits)
Output: 3

10. Comments

# This is a comment

You might also like