0% found this document useful (0 votes)
10 views6 pages

Python Introduction G6

This document provides an introduction to Python programming for Grade 6 CBSE students, covering basic concepts such as computer languages, programming languages, and the role of a programmer. It highlights Python's features, how to write and run Python programs in different modes, and explains fundamental programming concepts like operators, data types, variables, and input/output functions. Additionally, it includes examples and syntax rules to help students understand Python programming effectively.

Uploaded by

msaifparrakkal
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)
10 views6 pages

Python Introduction G6

This document provides an introduction to Python programming for Grade 6 CBSE students, covering basic concepts such as computer languages, programming languages, and the role of a programmer. It highlights Python's features, how to write and run Python programs in different modes, and explains fundamental programming concepts like operators, data types, variables, and input/output functions. Additionally, it includes examples and syntax rules to help students understand Python programming effectively.

Uploaded by

msaifparrakkal
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

Python – Introduction (Grade 6 CBSE Notes)

What is a Computer Language?


A computer language is a medium of communication between the user and the
computer.
A computer cannot understand human language. It understands only instructions.
What is a Program?
A program is a set of instructions given to a computer to perform a task.
What is a Programming language?
The process of writing instructions for a computer is called programming.
Who is a Programmer?
A person who writes programs is called a programmer.
What is a Programming Language?
A programming language is a set of words, symbols and rules used to write computer
programs.
Example: Python

PYTHON
Python is a high-level, structured, open-source programming language.
It was created by
 Guido van Rossum
 First released in 1991
Python is named after the comedy show
Monty Python's Flying Circus
Features of Python
1. Easy to learn and use.
2. Open-source and free.
3. Portable (runs on Windows, Linux, Macintosh).
4. Supports GUI programming.
5. Simple and natural syntax.
6. Interpreted language (executes line by line).
Example:
a=2
b=3
sum = a + b
print(sum)
Output: 5

GETTING STARTED WITH PYTHON


Python programs can be written in:
 Interactive Mode
 Script Mode
INTERACTIVE MODE (Using IDLE)
Python provides an environment called
IDLE(integrated and development learning environment)
When you open Python, you see:
>>>
This is called the Prompt.
Example:
print("Welcome to Python")
Output:
Welcome to Python
Best for small programs
Cannot save programs
SCRIPT MODE
Used to create and save programs.
Steps in IDLE:
1. Open IDLE
2. Click File → New File
3. Type program
4. Click File → Save
5. Save with .py extension
6. Press F5 to Run
Example File Name:
[Link]

OPERATORS
Operators are special symbols used to perform operations.
The values on which operators work are called operands.

ARITHMETIC OPERATORS
Operat Examp Outp
Meaning
or le ut
+ Addition 200+45 245
- Subtraction 100-20 80
Multiplicati
* 4*5 20
on
/ Division 28/4 7.0
Floor
// 50//6 8
Division
% Modulus 67%9 4
Operat Examp Outp
Meaning
or le ut

** Exponent 8**2 64

Concatenation (Strings)
"Good" + " " + "Morning"
Output:
Good Morning
Replication
"python" * 3
Output:
pythonpythonpython

LINES AND INDENTATION


Python is very strict about indentation.
What is Indentation?
Spaces at the beginning of a line of code.
Python uses indentation to define blocks of code.
Example:
if True:
print("Hello")
The space before print is indentation.
COMMENTS
Comments are used to explain code.
Python ignores comments.
Single Line Comment : Uses #
# This is a comment
print("Hello")
Multi-line Comment : Uses triple quotes: """ This is a multi-line comment """
STATEMENTS
A statement is an instruction that Python can execute.
Example:
num1 = 10
num2 = 20
add = num1 + num2
Each line is a statement.
DATA TYPES
Data type defines the type of data stored in a variable.
Integer (int)
Whole numbers without decimal.
Examples:
100
-88
12
a = 12
b = -20
Float
Numbers with decimal point.
Examples:
0.5
-4.567
12.5
a = 12.5
String
Sequence of characters.
Written inside:
 Single quotes ' '
 Double quotes " "
name = "reema"
password = 'reema@123'

VARIABLES
• Variables are containers for storing data values.
• A variable is created the moment you assign a value to it-initializing
variable.
Example:
num = 100
To print:
print(num)
Output:
100
Assigning Same Value to Multiple Variables
num1 = num2 = num3 = 10
Assigning Multiple Values in One Line
num1, num2, num3 = 10, 20, 30
Variable Naming Rules
✔ Can contain letters, numbers, underscore
✔ Cannot start with number
✔ No spaces allowed
✔ Cannot use keywords

Correct:
total_marks
shape_1
Wrong:
total marks
1num
INPUT AND OUTPUT FUNCTIONS
input() Function
Used to take input from user.
Syntax:
variable = input("Message")
Example:
name = input("Enter your name: ")
To know :
input() always returns string value.

print() Function
Used to display output.
Syntax:
print(variable)

PROGRAM 1
Program to get name and age
name = input("Enter your Name: ")
age = input("Enter your Age: ")

print(name)
print(age)

PROGRAM 2
Problem Without int()
num1 = input("Enter First Number: ")
num2 = input("Enter Second Number: ")
sum = num1 + num2
print(sum)
Input:
20
30
Output:
2030
Because input() returns string → concatenation happens.
PROGRAM 3
Using int() Function
num1 = int(input("Enter First Number: "))
num2 = int(input("Enter Second Number: "))
sum = num1 + num2
print(sum)
Output:
50
Now addition works correctly.
float() Function
Used to convert string to decimal number.
num = float(input("Enter Decimal Number: "))

You might also like