Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
39 views

Python Keywords

The document discusses Python programming language. It describes what Python is, its uses, syntax, keywords and how to write basic Python programs. Key points covered include Python's readability, flexibility and ability to connect to databases and handle large data.

Uploaded by

shalinikasera157
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Python Keywords

The document discusses Python programming language. It describes what Python is, its uses, syntax, keywords and how to write basic Python programs. Key points covered include Python's readability, flexibility and ability to connect to databases and handle large data.

Uploaded by

shalinikasera157
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Python Programming

Python is a programming language.


• Program: Program is a set of instruction which
is passes to computer for execution.
• Collection of programs called software.
• Software : Software is a bundle of programs.
• Development of software is stepwise process:
1. User requirements.
2. Feasibility study.
3. System Analysis.
4. Designing.
5. Coding.
6. Testing.
7. Implementation.
8. Maintenance.
* Algorithm is a sequence of steps that
gives method of solving a problem
Designing method:-Designing is the first step for
obtaining sol” of a given Problem there are
three basis opproach
1. Top Down Design:-
2. Bottom-up Design;-
3. Modular Approach:-
Programming Language:- the Programming
language can be classified into two type -
• Low-level language
• High-level language
1. Low-level language
A) Machine level language
B) Assembly language
A. Machine level language:-
 The machine language consists of instruction that are in
binary format (0) & (1).
 Computer can understands only machine level language.
 A machine level language program is error-prone and its
maintenance is very difficult.
 Machine language are not portable.
 Every computer has its own machine instruction; so the
program written for one computer are not valid for
another computer.
B. Assembly language:-
 In assembly language instruction are given in English
like words such as- Mov , Add , Sub etc.
 So it is easier to write and understands assembly
programs. Since a computer can understands only
machine level language, hence assembly language
program must be translate into machine language .
 The translator that is used for translating is called
“assembler”.
 In assembly language data is stored in computer
register and each computer has different set of
registers.
 Hence the assembly language program is also not
portable.
High level language:-
 High-level language are designed keeping in mind
the feature of portable i.e. these language are
machine independents.
 These are English like language , so it is easy to
write and understands the programs of high-level
language.
 For translating a high-level language program into
machine language , compiler or interpreter is
used.
 Every language has its own compiler or
interpreter
For ex. FORTRAN, COBOL, BASIC, PASCAL.ETC.
TRANSLATOR
Translator are just computer programs, which
accept a program written in high-level or low-
level language and produce on equivalent
machine language programs as output.
Tree type of translator used are
 Assembler
 Compiler
 Interpreter.
Python
• Python is a programming language.
• Python can be used on a server to create web
applications.
• Python is a popular programming language. It
was created in 1991 by Guido van Rossum.
• It is used for:
1. web development (server-side),
2. software development,
3. mathematics,
4. system scripting.
What can Python do?
• Python can be used on a server to create web
applications.
• Python can be used alongside software to create
workflows.
• Python can connect to database systems. It can
also read and modify files.
• Python can be used to handle big data and
perform complex mathematics.
• Python can be used for rapid prototyping, or for
production-ready software development.
Why Python?
• Python works on different platforms (Windows, Mac,
Linux, Raspberry Pi, etc).
• Python has a simple syntax similar to the English
language.
• Python has syntax that allows developers to write
programs with fewer lines than some other
programming languages.
• Python runs on an interpreter system, meaning that
code can be executed as soon as it is written. This
means that prototyping can be very quick.
• Python can be treated in a procedural way, an object-
orientated way or a functional way.
Python Syntax compared to other
programming languages
• Python was designed to for readability, and has
some similarities to the English language with
influence from mathematics.
• Python uses new lines to complete a command,
as opposed to other programming languages
which often use semicolons or parentheses.
• Python relies on indentation, using whitespace,
to define scope; such as the scope of loops,
functions and classes. Other programming
languages often use curly-brackets for this
purpose.
HOW to Open:
• Start button--Python-- IDLE

• File Menu  new file(press enter)


• Write your code
• Save (ctrl + s)
• Run your program(F5)
Python Token
1. Keywords
2. Identifier
3. Delimiter
4. Data Type
5. Operators
6. Function
Keywords
• Keywords are predefined words which have
some specific meaning in Python.
• They always written in lower case except True
& False.
• There are 33 words as reserved word in
Python 3.10 and 35 words as a reserved word
in Python 3.11
Keywords Description
and This is a logical operator which returns true if both the operands are true else returns false.

or This is also a logical operator which returns true if anyone operand is true else returns false.

not This is again a logical operator it returns True if the operand is false else returns false.

if This is used to make a conditional statement.

Elif is a condition statement used with an if statement. The elif statement is executed if the
elif
previous conditions were not true.

Else is used with if and elif conditional statements. The else block is executed if the given
else
condition is not true.

for This is used to create a loop.

while This keyword is used to create a while loop.

break This is used to terminate the loop.

as This is used to create an alternative.

def It helps us to define functions.

lambda It is used to define the anonymous function.

pass This is a null statement which means it will do nothing.


return It will return a value and exit the function.

True This is a boolean value.

False This is also a boolean value.

try It makes a try-except statement.

with The with keyword is used to simplify exception handling.

This function is used for debugging purposes. Usually used to check the
assert
correctness of code

class It helps us to define a class.

continue It continues to the next iteration of a loop

del It deletes a reference to an object.

except Used with exceptions, what to do when an exception occurs

Finally is used with exceptions, a block of code that will be executed no


finally
matter if there is an exception or not.

from It is used to import specific parts of any module.


global This declares a global variable.

import This is used to import a module.

It’s used to check whether a value is present in a list, range, tuple,


in
etc.

is This is used to check if the two variables are equal or not.

This is a special constant used to denote a null value or avoid. It’s


none important to remember, 0, any empty container(e.g empty list) do
not compute to None

nonlocal It’s declared a non-local variable.

raise This raises an exception.

yield It ends a function and returns a generator.

async It is used to create asynchronous coroutine.

await It releases the flow of control back to the event loop.

You might also like