Docsity

Python Programming Complete Notes – Beginner to Advanced, Study notes of Computer Programming

Toggle sidebar
bg1
What is Program?
Program is a set of instructions, written in computer
Language, to perform a specific task.
Or
A set of instructions that directs a computer's
hardware to perform a task is called a program.
To solve a problem one has to write step by step solution
using simple instruction.
Procedure for solving a problem:-
It is the process involving basic sequential step to arrive
at the solution of given problem.
There are basic 6 steps to solve a problem:-
1. Understanding the Problem.
2. Construct a List of variables the are needed to get the
solution.
3. Decide the Layout/method for output presentation.
4. Select the Programming technique which is best.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34

Partial preview of the text

Download Python Programming Complete Notes – Beginner to Advanced and more Study notes Computer Programming in PDF only on Docsity!

What is Program?

Program is a set of instructions, written in computer Language, to perform a specific task. Or A set of instructions that directs a computer's hardware to perform a task is called a program. To solve a problem one has to write step by step solution using simple instruction. Procedure for solving a problem:- It is the process involving basic sequential step to arrive at the solution of given problem. There are basic 6 steps to solve a problem:-

  1. Understanding the Problem.
  2. Construct a List of variables the are needed to get the solution.
  3. Decide the Layout/method for output presentation.
  4. Select the Programming technique which is best.
  1. Test the Program.
  2. Finally use the data validation steps

What is Programming?

A computer program consists of code that is executed on a computer to perform particular tasks. This code is written by programmers.

  • Programming is the process of giving machines a set of instructions that describe how a program should be Perform.
  • Programmers will start by using a code editor or IDE to write what is called source code.
  • Source code needs to be converted into machine language so machines can understand the instructions and execute the program.
  • This process of converting source code into machine language is known as compiling.
  • Examples of compiled programming languages would be C and C++.
  • Examples of interpreted programming languages would be JavaScript and PHP. Here are a few popular programming languages.

 The programmer writes a sequence of instruction called program  Types of computer languages

  1. Machine level language & low level language
  2. Assembly language & middle level language
  3. High level language.

Low level language & machine language

 Set of instruction codes , which are directly understood by computer.  First-generation language is the lowest level computer language. Information is conveyed to the computer by the programmer as binary instructions  Low level languages are the machine codes in which the instructions are  Low level languages are the machine codes in which the instructions are given in machine language in the form of 0 and 1 to a Computer system.

Assembly Language:

 Assembly Language is the second generation programming language  Language which involves letters, symbols and mnemonics for the execution the operation code. Eg ADD, SUB,CMP (mnemonics).  Eg.  ADD B  STORE C  TYPE HALt The programs that have been written using words, names and symbols in assembly language are converted to machine language using an Assembler.Because a Computer only understands machine code languages.

High level language:

 The high level languages are the most used and also more considered programming languages that helps a programmer to read, write and maintain. It is also the third generation language that is used and also running till now by many programmers. The translator may be an interpreter and Compiler that helps to convert into binary code for a Computer to understand.  It is user-friendly as the programs are written in English using words, symbols,characters, numbers that needs to be converted to machine code for processing

1. Assembler

 When a program is written in a language other than machine language is not understood by any computer.  So a program written in other language need to be translated into machine language before it is executed.  This translation is done with the help of software called assembler

2.Interpreter

 It is a program to translate the high level language program onto machine language.  It occupies less memory space. But it is slower then complier.  Interpreter converts the high-level program into an intermediate language.  which can be executed immediately. And this all is done line by line or statement by statement.  some examples are Ruby, Python, PHP and many more

3.Complier

 A compiler is a program that translates computer code written in a high-level programming language into low-level programming language code which can be immediately executable by a computer or another similar program. this all is done whole program.

TYPES OF ERROR IN PYTHON:

 Syntax errors

 Runtime errors

 Logical errors

1.Syntax errors:-

 Syntax errors occur in the programs when the rules or syntax of the programming language is not followed this errors occur with incorrect punctuation, word sequence or misuse of terms. This can caused either by opening brackets without closing them.

 A=b*c  But has been written as  A=b+c  2. mistake of <(less then),(> greater then) symbol.

PYTHON:-

Python Programming Language:-

 Python is easy, simple and highly flexible.  Python is a powerful high-level , interpreted, interactive and objectoriented-scripting language. It was designed to be easily readable; it uses English keywords frequently whereas other language use punctuation.  It is a high level programming language developed by Guido van Rossum in 1991 at National Research Institute for Mathematics,Netherlands.  It is presently owned by Python software Foundation (PSF

Features of Python:-

  1. Python is an interpreted, interactive, directly executed language.
  2. It is free open-source software having large repository of libraries.
  1. It is extensible and highly efficient as there is no wastage of time in declaring variables.

4. Interpreted Language : Python is an Interpreted

Language because Python code is executed line by line at a time. like other languages C, C++,Java, etc. there is no need to compile python code this makes it easier to debug our code. The source code of python is converted into an immediate form called byte code.

5. python is object-oriented : A programming

language that can model the real world is said to be object-oriented. It focuses on objects and combines data and functions. Python supports both procedure- oriented and objectoriented programming which is one of the key python features.

6. Python is interactive : this means that you can

actually work at a python prompt and interact with the interpreter directly to execute your programs and get the output.

7. Python is beginner’s language : python is a

greater language for beginner programmers as the language is interpreted. It also supports the development of a wide range of applications, forms simple text processing to WWW(World Wide Web) browser to games

8. Python is complete language : when you

install python, you need not download and install additional libraries. All types of required functionalities are available through various modules.

used for web development(server-side), software development.  The popular YouTube video sharing service is largely written in python.  Today python has become language of choice for data scientists.  Python is also used to development Android apps.

Tokens

Smallest individual unit in a

program is known as token.

1. Keywords

2. Identifiers

3. Literals

4. Operators

5. Delimiter

1.Keywords

At the time of designing a language, some words are reserved to do specific tasks. Such words called keywords or reserved words. They are used to defined the syntax and structure of the python language. ne break except in raise False await else import pass and continue for lambda try True class finally is return as def from nonlocal while async elif if not with assert del global or yield  Keyword cannot be used as a variable name.  All keyword are small letters except (False, None, and True)  To display the list of keyword in python we used:  >>>import keyword  >>>print(keyword.kwlist

2.Identifiers

Eg:- a=7 #integer literal b=2.25 #float literal c=3.14*j #complex literal.

 Boolean literals : Boolean literals are used to

denote Boolean values. They contain either True or False Eg:- Isboolean=True # Boolean literal. ariable

4.variable:-

 Variables are reserved memory locations to store values. This means that when you create a variable

you reserve some space in memory.

 Based on the data type of a variable, the interpreter allocates memory and decides what can be stored in the reserved memory. Therefore, by assigning

different data types to variables, you can store integers, decimals or characters in these variables.  Eg  >>>x=  >>>x*  10

Multiple Assignment

 python allows you to assign a single value to several variables simultaneously. For example –  a = b = c = 1  a,b,c = 1,2,“pooja“  Here, two integer objects with values 1 and 2 are assigned to variables a and b respectively, and one string object with the value "john" is assigned to the variable c.

Rules for creating variables

in Python:

Data types

 Data types are the classification or categorization of data items. It represents the kind of value that tells what operations can be performed on a particular data

Number

 Integers – This value is represented by int class. It contains positive ornegative whole numbers (without