2. Python Programming
• Introduction To Python
• Using Variables In Python
• Basics Of Programming Python
• Connecting To SQLite Database
• Developing a GUI with PyQT
Slide 2
3. Introduction To Python
• Python is a general purpose interpreted interactive object oriented and high level
programming language .
• It was first introduced in 1991 by Guido van Rossum, a Dutch computer programmer.
• The language places strong emphasis on code reliability and simplicity so that the
programmers can develop applications rapidly.
• Python is multiprogramming language, which allows user to code in several different
programming styles.
• Python is widely used for scripting in Game menu applications effectively.
• Most programs in Python require considerably less number of code to perform the same
task compared to other languages like C. So less programming errors and reduces the
development time needed also.
Slide 3
4. Installation Of Python
• To learn language first, we have to download the software which is Python Interpreter.
• To download Python Interpreter we go to the site https://www.python.org/downloads and
click on the suitable icon. The website appears as below
Slide 4
5.
6. Data Types And Variables
Data Types are classification of data items
Slide 6
7. • Numeric – Any representation of data which has numeric value. Python
identifies three types of numbers- integers, float and complex number.
(a) Integer- Positive and negative whole numbers. Ex- 1234, -23 etc.
(b) Float- Real numbers with a floating point representation in which the fractional
component is denoted by a decimal or scientific notation. Ex- 55.55, -66.7
(c) Complex Number- A number with a real and imaginary component is represented as a+bj
in Python. Ex- 5+6j
• Boolean- Any representation of data which has two values denoted by True and False.
• Sequence- An ordered collection of similar or different data types. The built-in Sequences
data types are – String, List, and Tuple.
Slide 7
8. (a) String- A collection of one or more characters put in single, double or triple
quotes. Ex- ‘Hello’, “Hello”
(b) List- An ordered collection of one or more data items, not necessarily of same type, put in
square brackets .Ex - [1,”Ravi”,75.50]
(c) Tuple- An ordered collection of one or more data items, not necessarily of same type put in
parentheses. Ex - (1, “Ravi”, 75.50)
• Dictionary- An ordered collection of data in key:value pair form. Collection of such pairs is
enclosed in curly brackets. Ex – {1:”Iron Man”, 2:”Thor”, 3:”Captain America”}
Slide 8
9. Variables
Variables are the name given to the data that we need to store and manipulate in our program.
For example, to store the age of the user, we can write a variable userAge and its is defined as
below.
userAge=0 or userAge=30
A variable can have short name. A variable start with a letter or the underscore character.
A variable cannot start with a number. A variable name can only contain alpha-numeric and
underscores(A-z, 0-9, _).
Slide 9
10. Basics Of Programming
Program- It is set of instruction given to computers to perform a task.
Computer Programming- It consists of two steps.
Slide 10
11. Operators In Python
• Arithmetic Operators- These operators are used to perform basic mathematic operations. Ex-
Addition x + y, Subtraction x – y, Multiplication x * y.
• Assignment Operators- It is use to assign the value to the variables. Ex – x=5, x=x+3.
• Comparison Operators- These operators compares the operands present on either side.
Ex- x>y, x==y. It will give either true or false.
• Logical Operators- These operators are python keywords that are used for joining two
Boolean expression. Types of logical operators are-
Slide 11
12. Conditional Statements
If Statement
It is one of the commonly used control flow statements. It allows the program to evaluate if
certain condition is met. It is used for decision making.
Slide 12
13. Else Statement
The else statement is usually used when we have to judge one statement on the
basis of other. If one condition goes wrong, then there should be another condition that
should justify the statement or logic.
Slide 13
14. Loops In Python
If the program close redirected towards any of earlier statement in the program than it is
known as a loop. Types Of Loops-
(a) While Loop
(b) For loop
Slide 14
15. While Loop
In python, while loop is used to execute a block of statement until a given condition
is satisfied. And when the condition become false, the line immediately after the loop in
program is executed. Syntax-
Slide 15
16. For Loop
It is a control flow statement for specifying iteration, which allows code to be executed
repeatedly. It starts with for keyword.
Slide 16
17. Connecting to SQLite Database
Database- It is a collection of related data. It is a special type of computer file. Database is
centralized program independent and organized collection of data which removes data
redundancy and ensure data integrity.
Database Model-
(a) Network Model
(b) Hierarchical Model
(c) Relational Database Model
Relational Database
Data organized in one or more table called Relations. Each table represent one entity.
Slide 17
18.
19.
20. Relational Database Management
System
It is software for creating and managing database. It makes possible for us to read, create,
update, delete data in a database. RDBMS software uses special language to communicate
with database. This language is called Structured Query Language. The statement in SQL are
classified into five categories-
(a) Data definition language
(b) Data retrieval
(c) Data manipulation
(d) Transaction control
(e) Data control
Slide 20
24. Accessing SQLite Database using
Python
Python has a standard mechanism for accessing databases called DB-API. We need DB-API because
there need to be a standard way in which python program can connect to different databases.
The standard python distribution has inbuilt support for SQLite database connectivity. It contains
squlite3 module.
25.
26. Developing a GUI using PyQT
The graphical user interface(GUI) is a form of user interface that allows users to interact with
electronic devices through graphical icons and visuals indicators. We can build GUI for
application using graphics library. This graphic library contains widgets. GUI applications are
designed to be event driven. Event means user does something by click of a button, drag,
mouse or type in text box.
27.
28.
29. Application Of Python
• Used to develop different application like web application, graphic user interface, software
development application, network programming.
• Use of python help in accessing the data base easily.
• Used in Raspberry Pi to interface different I/O device.
• Used in Image Processing
• For Automation
• Used as embedded scripting language.
Slide 29