Page |1
CBSE Class 11th
Computer Science With Python
COMPUTER ACADEMY
9559961111
Page |2
What is a Program?
A program is a set of instructions given to a machine to process and give us a
meaningful result (Output).
Why Programs are needed?
Automation , Speed , Accuracy
COMPUTER ACADEMY
9559961111
Page |3
High Level Language Computer Programming languages
can be easily understood by the
(Source Code)
programmers (human)
e.g. c , c++ , Java , Python, etc.
It convert the program from High
Language Processor Level to machine language
Compiler , Interpreter
(Assembler for Assembly Lang)
Computer Programming languages
can be easily understood by the
Low Level Language machine.
e.g. Binary / Machine Language
COMPUTER ACADEMY
9559961111
Page |4
Difference between Compiler and Interpreter :
Compiler Interpreter
It covert the whole source code to machine level It covert the source code to machine level line
in one go. by line.
It show all the errors together if any present. It show only one error at a time.
Its execution is fast. Its execution is slow.
Java , c , c++ are some example of Python , Perl are some example of programming
programming languages which use Compiler. languages which use interpreter.
COMPUTER ACADEMY
9559961111
Page |5
Coding
(Writing the instructions)
Compile
(High Level to Low Level conversion)
Execute / Run
(Performing the instructions given)
COMPUTER ACADEMY
9559961111
Page |6
PYTHON
Python is an interpreter based, high-level, general-purpose, case sensitive, object oriented
programming language. It was created by Guido van Rossum in 1991.
Guido; named it on a famous BBC TV serial Monty Python’s Flying Circus.
Python is based on ABC language and Modula-3
Character set of python language: A character set is a set of valid characters acceptable by a
programming language in scripting. These are the characters we can use during writing a script in
Python. Python supports all ASCII / Unicode characters that include:
Alphabets: All capital (A-Z) and small (a-z) alphabets.
Digits: All digits 0-9.
Special Symbols: Python supports all kind of special symbols like, " ' l ; : ! ~ @ # $ % ^ ` & * ( ) _
+-={}[]\.
White Spaces: White spaces like tab space, blank space, newline, and carriage return.
Other: All ASCII and UNICODE characters are supported by Python that constitutes the Python
character set.
COMPUTER ACADEMY
9559961111
Page |8
Tokens:- The smallest individual element of a Python program is called as token. There are 5 types
of token in Python –
i) Keywords: Words which have a specific meaning towards the Python interpreter .
OR
Pre-defined reserved words of Pyton programming language.
There are total 33 keywords are there in Python 3.7.
e.g. if, for, break, class, while, try ….. etc.
ii) Identifiers: All the user defined elements of a Python program.
e.g. a , xyz , x1 , student_1, name_ , _abc , a_2_1
iii) Literals: Elements of a Python program whose value remain fix during a program run. Also
known as Constants.
e.g. 10, 2.5, “Hello” , ‘t’ ,True
Types of literals – Numeric literal, Boolean literal, String literal, Special literal None, Literal collections
iv) Operators: These are the symbols which perform a specific operation on their operands.
e.g. - + , <, /, %, , != ……. etc.
v) Punctuators / Separators: These are the symbols used for syntax and structure of a program.
e.g. . , : ( ) { } [ ]
COMPUTER ACADEMY
9559961111
Barebones of Python Program:
Functions – set of statements having a name and can be used/ reused anywhere where needed by
its name.
Statements – an instruction given to machine to perform an action (max 79 character)
Expression – any legal combination of symbols that represents a value.
Comments – non- executable lines written in a program for documentation purposes.
Block – a group of statements which are sub part of a program or a function.(Also called suite
code-block and suite )
Indentation– an indent of 4 spaces together to represent the block boundaries.
Comment
Indent Function
Expression
Statement
P a g e | 10
Comments
These are non- executable lines written in a program for documentation purposes.
Types of comments :
1) Single Line comment: It is represented by #. Whatever is written on the Right side of # sign in
same line become comment.
Example:
Single Line
#Function to ………………
Comment
#..........................
Executable
Statements
2) Multi – Line Comments: Actually it not designed as comments but we can use it as comments.
Whatever in written in-between triple quotes works as comments.
' ' '………………………. " " "………........................
…………………………… …………………………
………………………….' ' ' …………………………………….." " "
COMPUTER ACADEMY
9559961111