0% found this document useful (0 votes)
25 views5 pages

Unit 3 Python Programming 11th

A detailed analysis and help to navigate the challenging world of computer science. It will help you to understand and practice computer science early on. Wishing you success for your journey, as this will be a very easy guide.

Uploaded by

ziaraoofparrey
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)
25 views5 pages

Unit 3 Python Programming 11th

A detailed analysis and help to navigate the challenging world of computer science. It will help you to understand and practice computer science early on. Wishing you success for your journey, as this will be a very easy guide.

Uploaded by

ziaraoofparrey
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
You are on page 1/ 5

UNIT-3 PYTHON PROGRAMMING

Introduction of PYTHON
Python is a high level , interpreted , interactive and object oriented scripting language. Python is designed
to be highly readable. It uses English Keywords frequently whereas the other languages uses punctuations
HISTORY OF PYTHON
Python was developed by Guido van Rossum in the last 80’s and 90’s at the National Research Institute for
Mathematics and Computer Science in the Netherlands.
Q. What are the features of Python ?
1. Python is a high level language. It is a free and open source language.
2. It is an interpreted language, as Python programs are executed by an interpreter.
3. Python programs are easy to understand as they have a clearly defined syntax and relatively simple
structure.
4. Python is case-sensitive. For example, NUMBER and number are not same in Python.
5. Python is portable and platform independent, means it can run on various operating systems and
hardware platforms.
6. Python has a rich library of predefined functions.
7. Python is also helpful in web development.
Apart from these there are some more features of python : • Easy to learn • East to read • Easy to maintain
• Interactive mode • GUI programming • Easily integrated with C, C++ , Java etc
Q. What are character set ?
Character Set The character set can be an alphabet , digit or any special symbol , which is used to represent
information. Eg. Alphabets (A,B,C..........Y,Z) (a,b.....y,z) Digits (0,1,2,3.......9) Special symbol (;,[,(,^,% )
What are tokens ?
The smallest individual unit in a program is called as token or a lexical unit. Python tokens are : Keywords ,
Identifiers , Literals and Operators.
Q. What are keywords ?
Keywords are words that have some special meaning or significance in a programming language. They are
used for their special features. In Python we have 33 keywords .

What are identifiers ?


Identifiers are the names given to any variable , function , class , list , methods , etc for their identification.
Python is a case sensitive language and it has some rules and regulations to name an identifier. Here are
some rules
1. An identifier can’t be a keyword
2. Identifier starts with a capital letter (A-Z) , a small letter (a-z) or an underscore(_).
3. Any other special characters or whitespaces are strictly prohibited in an identifier.

1|Page HSS/ D / IT-IT ES/ 3


Q. What are the barebones in python programming?
The barebones of python program are Expressions, Statements, Comments,
Functions, Block and Indentation.
1) Expressions: They are the combination of symbols with values to evaluate.
2) Statement: These are Instructions that python can execute. eg: a=1
3) Comments: This is the additional information about the statement. There are single and multiline
comments available. These are ignored by Interpreter.
4) Functions: It is itself a small program that takes input and processed and gives
output. eg: print(), input()
5) Block and Indentation: Block is a piece of code that executes as a unit. Indentation is a space given
for better readability and understanding.
CREATE A VARIABLE
Rules for creating variables in Python:
1) A variable name must start with a letter or the underscore character.
2) A variable name cannot start with a number.
3) A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and
_ ).
4) Variable names are case-sensitive (name, Name and NAME are three different variables).
5) The reserved words(keywords) cannot be used naming the variable.
Sample program
# An integer assignment
age = 45
# A floating point
salary = 1456.8
# A string
name = "John"
print(age)
print(salary)
print(name)
DATA TYPES
Every value belongs to a specific data type in Python. Data type identifies the type of data values a
variable can hold and the operations that can be performed on that data. Figure enlists the data
types available in Python.

2|Page HSS/ D / IT-IT ES/ 3


1. Integer : Integer data type stores numerical values only . It further classified into three types : int , float
and complex
2. Sequences : A Python sequence is an ordered collection of items , where each item is indexed by an
integer. The three types of sequence are :
a. String : It is a group of characters enclosed in single quotes or double quotes. The characters may be
alphabets , digits , or special characters including spaces.
b. List : list is a sequence of items separated by commas and the items are enclosed in square brackets [].
c. Tuple : tuple is a sequence of items separated by commas and items enclosed in ().
3. Set : Set is an unordered collection of items separated by commas and the items are enclosed in curly
brackets {}. It is similar to list , except that it cannot have duplicate entries.
4. None : None is a special data type with a single value . it is used to signify the absence of value in a
situation. None supports no special operation and it is neither FALSE nor 0.
5. Mapping : mapping is an unordered data type in Python. Currently there is only one standard mapping
data type called Dictionary.
Types of errors in python programming.
Errors are problems that occur in the program due to an illegal operation performed by the user or by the
fault of a programmer, which halts the normal flow of the program. Errors are also termed bugs or faults.
There are mainly three types of errors in python programming.
1. Syntax Errors
A syntax error is one of the most basic types of error in programming. Whenever we do not write the proper
syntax of the python programming language (or any other language) then the python interpreter or parser
throws an error known as a syntax error.
2. Logical errors
These are the most difficult type of error to find, because they will give unpredictable results and may crash
your program. A lot of different things can happen if you have a logic error.
3. Run time errors
Run time errors arise when the python knows what to do with a piece of code but is unable to perform the
action. Since Python is an interpreted language, these errors will not occur until the flow of control in your
program reaches the line with the problem.
What is Statement in Python
A Python statement is an instruction that the Python interpreter can execute. There are different types
of statements in Python language as Assignment statements, Conditional statements, Looping
statements, etc.

STATEMENT FLOW CONTROL


A flow control statement defines the flow of the execution of the program. Python programming language
provides the following types of decision making statements

3|Page HSS/ D / IT-IT ES/ 3


1. If statement : an if statement consists of a Boolean expression followed by one or more statements.
Syntax : if expression:
Statement (s)

2. if-else: The if-else statement evaluates the condition and will execute the body of if if the test condition
is True, but if the condition is False, then the body of else is executed.

4|Page HSS/ D / IT-IT ES/ 3


3. nested if: Nested if statements are an if statement inside another if statement.

4.if-elif-else: The if-elif-else statement is used to conditionally execute a statement or a block of


statements.

5|Page HSS/ D / IT-IT ES/ 3

You might also like