Related Video: https://youtu.be/kyh9qQbf_uk
Monday, 24 June 2019
Special Operators
Related Video: https://youtu.be/kyh9qQbf_uk
Assignment Operators
=
|
==
|
a=b
|
a==b
|
i.e we are assigning the value of variable ‘b’ to left hand side
variable ‘a’
|
We comparing two variables, which returns Boolean True/False
|
Print(a)
|
print(a==b) or print(b==a) # compares, we get result True or false
|
Output: 20
|
Output: True
|
Ordered
a=[10,"raj", 12.45,True,2+3j]
print(a)
print(a[0])
#output: Same order only the output displays
10,"raj", 12.45,True,2+3j
10
Immutable
Every object reference holds an object data(instance). When an object is created, it is assigned a unique object address(id). Its data type is defined at runtime and once set can never change, However its state can be changed if it is mutable. Simple put, a mutable object can be changed after it is created, and an immutable object can’t.
Next topic: List
Conditional Statements
Related Video: https://www.youtube.com/watch?v=_cS3R_6SbRc&feature=youtu.be
Next Topic:if else statement
Previous Topic: Control statements (Related Video: https://www.youtube.com/watch?v=c2AzRkJRruY&feature=youtu.be )
Wednesday, 19 June 2019
Database connectivity SQLite
Database Connectivity:
#Step1 import the sqlite
import
sqlite3 as s
#step2:
conn=s.connect('escdb.db')
print("Database
opened successfully")
Steps:
To
create
Persistanece: OOP’s
Class,object,
abstraction,encapsulation,inheritance,polymorphsm…persistence
Files…
Java,
python,…
To
store the data we can use:
Files
or database.
File: A file can data in the secondary memory
ex: hard disk. It can store text format or binary format. Data is stored
unformatted
Database:
collection of data. We can store the data in the database
Once
the data is stored in a database, we need to perform operations on data.
Operations:
Modification
to the existing data
Deletion
for unnecessary data
Reading
/Retrieving the data from the database
These
operations is called Database Management systems (DMBS)
Dbms=db+application(Java/Python/…)
Advantages of DBMS:
1. Storing and
retrieving the data is so simple to compared to files by
Using SQL(Structured Query
Language) Commands we can perform.
2.
We can not store the huge amount of data in the files
whereas we can store in Database
3.
Relationship is not possible to maintain in the files
4.
Multiple users can retrieve or access the database
simultaneously.
5.
If any changes are done, we can not rollback to the
files
6. Files are very weak
security. Whereas DBMS Offers good security.
Example
2:
#creating
table
#import
the sqlite
import
sqlite3 as s
conn=s.connect('escdb.db')
print("Database
opened successfully")
conn.execute('''CREATE
TABLE APSSDC(
ID
INT PRIMARY KEY NOT NULL,
NAME
TEXT NOT NULL,
AGE
INT NOT NULL,
ADDRESS
CHAR(50),
SALARY
REAL);''')
print("Table
created successfully")
conn.close()
"""
Database
opened successfully
Table
created successfully
"""
Steps to connect to SQLite:
1. Import the module.
Ex: import sqlite3.
2.
Use connect() method of a sqlite3 module and pass the
actual parameter with database name as
an parameter/argument. Ex: conn=s.connect('escdb.db')
3. Perform sql
operations: Example: conn.execute(‘’’……’’’’)
Import sqlite3: we can use all the classes,method of sqlite3 module
Sqlite3.connect(): We can create connection to the SQLite Database.
If
you want to use any database, first we should be installed in our system then
only we can create database.
We
have so many database in the market:
1. Oracle
2.
GadFly
3.
mSQL
4.
MySQL
5.
PostgreSQL
6.
Microsoft SQL Server 2000
7. IBM DB2
Tuesday, 4 June 2019
Arithmetic Operators
Example:
For arithmetic operators, we will take a simple example of addition where we will add two-digit 4+5=9
Operator
|
Meaning
|
Example
|
Output
|
+
|
Addition
|
a=2+3
|
print(a): 5
|
-
|
Subtraction
|
a=4-2
|
print(a): 2
|
*
|
Multiplication
|
a=2*3
|
6
|
/
|
Division: divides left
operand by the right operand
|
a=4/2
|
2
|
%
|
Modulus gives a remainder of
division
|
4%2
|
0
|
//
|
Integer division. Floor
division. Performs division and gives only integer quotient.
|
5//2
|
2
|
**
|
Exponent operator
|
10**2
|
100
|
Priorities of Arithmetic operators:
-->Now '+' operator is evaluated i.e a=8
--->Now '=' assignment operator is evaluated i.e 8 is stored in variable 'a'
Previous topic: Operators
Files with Exception handling
#Ask the user to take two input integer values var a,b try: a=int(input("enter any integer value:")) b=int(input(...
-
1. Python Introduction Features of Python https://youtu.be/09akrj25-IM https://youtu.be/09akrj25-IM Applic...
-
Database Connectivity : #Step1 import the sqlite import sqlite3 as s #step2: conn=s.connect('escdb.db') print("Data...
-
#Ask the user to take two input integer values var a,b try: a=int(input("enter any integer value:")) b=int(input(...