Docsity

Python Variables, Expressions, Statements, and Operators, Lecture notes of Software Engineering

Partial preview of the text

Download Python Variables, Expressions, Statements, and Operators and more Lecture notes Software Engineering in PDF only on Docsity!

INT

PYTHON PROGRAMMING

P.Raja,

Assistant Professor in Embedded System

Design(D4),

School of Electronics and Electrical

Unit I

 (^) Introduction : python programming language, introduction to program and debugging, formal and natural language  (^) Variables, Expression and Statements : Values and types, variables, variables name and keywords, statements, operators and operand, order of operations, operations on string, composition and comments  (^) Conditionals and Iteration : modulus operator, Boolean expressions, logic operators, conditional, alternative execution, nested conditionals and return statements, while statements, encapsulation and generalization  (^) Functions and recursion : function calls, type conversion and coercion, math functions, adding new function, parameters and argument, recursion and its use.

IEEE spectrum list of top programming language 2021. The list of programming languages is based on popularity.

Cont…

 general-purpose programming language

 you can use Python to write code for any

programming task

 in the Google search engine

 In mission-critical projects at NASA

 in transaction processing at the New York Stock

Exchange.

 Python is interpreted

 Python is an object-oriented programming (OOP)

language

Features of Python programming

Glossary:

Problem-solving:
The process of formulating a problem, finding a solution, and expressing
the solution.
High-level language:
The python language is designed to be easy for humans to read and write.
Low-level language:
A programming language that is created to be easy for a computer to
execute; also called “Machine language” or “Assembly language”.
 Interpreter:
To execute a program in a high-level language by changing it one line at a
time.

Cont…  (^) Compiler:  (^) To translate a program written in a high-level language into a low-level language all at once, in preparation for later execution.  (^) Source code:  (^) A program in a high-level language before being compiled.  (^) Object code:  (^) The output of the compiler after it translates the program.  (^) Executable:  (^) Another name for object code that is ready to be executed.

Cont…  (^) Debugging:  (^) The process of finding and removing any of the three kinds of programming errors.  (^) Syntax:  (^) The structure of the program.  (^) Syntax error:  (^) An error in a program that makes it impossible to parse (and therefore impossible to interpret).

Cont…  (^) Runtime error:  (^) An error that does not occur until the program has started to execute but that prevents from continuing.  (^) Exception:  (^) Another name for run time error.  (^) Semantic error:  (^) An error in a program that makes it do something other than what the program intended.  (^) Semantics:  (^) The meaning of the program.

Types of Literals in Python  (^) Literals in Python is defined as the raw data assigned to variables or constants while programming.

Python Identifiers

 An identifier is a name given to entities like class, functions, variables,

etc. It helps to differentiate one entity from another.

 Rules for writing identifiers

i. Identifiers can be a combination of letters in lowercase (a to z) or

uppercase (A to Z) or digits (0 to 9) or an underscore _. Names like

myClass, var_1 and print_this_to_screen, all are valid example.

ii. An identifier cannot start with a digit. 1variable is invalid, but

variable1 is a valid name.

iii. Keywords cannot be used as identifiers.

iv. We cannot use special symbols like! , @ , # , $ , % etc. in our identifier.

v. An identifier can be of any length.

Python Keywords

False def if raise

None del import return

True elif in try

and else is while

as except lambda with

assert finally nonlocal yield

break for not await

class form or async

continue global pass