Skip to content

Computer Science Class - 12 Notes

Python

Python is a high-level, interpreted programming language known for its simple, readable syntax and broad versatility. It supports multiple programming paradigms, including procedural, object-oriented, and functional programming. Python is widely used in web development, data analysis, artificial intelligence, automation, and software development due to its large standard library and a vast ecosystem of third-party packages.

Keywords & Identifiers

Keywords are reserved words. Each keyword has a specific meaning to the python interpreter, and we can use a keyword in our program only for the purpose for which it has been defined.

Identifier : In programing languages, identifiers are names used to identify a variable, function or other entities in a program.

Common Keywords : True, def, and, del.

Variables

Container for storing data. It allocates memory to store data values.

x = 5
name = "dan"

Operators in Python

  1. Arithmetic Operator
  2. Comparison Operator
  3. Logical Operator
  4. Assigment Operator
  5. Identity Operator
  6. Membership Operator

Flow Control

  1. Selection - Conditional ( if, elif, else )
  2. Repetition - loops ( for, while )

for loops are used to traverse through a sequence.

Data Structures


String

Sequence of characters.
Created using a single quote, double quote, triple quotes.

Characters in string can be accessed using indexes.

String Operations

  1. Concatenation
  2. Repetition
  3. Membership
  4. Slicing

String Functions

  • len
  • title
  • count
  • split
  • partition

List

  • sequence data type
  • store multiple values
  • can store different data types.

Tuple

  • sequence data type
  • store multiple values
  • can store different data types.
  • Tuple is immutable

Dictionary

  • Items are stored as key value pairs.
  • keys are unique.

Functions

Code block that is executed on call. Functions can take in positional and keyword arguments.

Database Management

Limitation of File System ( Need or Database )

  • DATA COMPLEXITY
  • DATA REDUNDANCY
  • DATA INCONSISTENCY
  • DATA ISOLATION
  • DATA DEPENDENCY
  • UNCONTROLLED DATA SHARING

Characteristics of Database Management Sytem

  • IT HIDES CERTAIN DETAILS ABOUT HOW DATA ARE ACTUALLY STORED AND MANAGED.
  • IT PROVIDES USERS WITH AN ABSTRACT VIEW OF DATA.
  • IT PROVIDES SET OF PROGRAMS TO MANAGE STORED DATA.
  • IT ACTS AS AN INTERFACE BETWEEN DATABASE AND END USER APPLICATION PROGRAMS.
  • IT CAN BE OF ANY SIZE AND COMPLEXITY.

Uses

  • BANKING
  • INVENTORY
  • PAYROLL
  • ONLINE SHOPPING
  • RESERVATION SYSTEM
  • HEALTHCARE

RDBMS

RDBMS stands for : Relational Database Management System.

Relation : Table

Attribute - Column

Tuple - Row

Domain - Data Type

Degree - Number of Columns

Cardinality - Number of Rows

Keys - Validations ( Primary Key )

If a table has 4 Rows, its cardinality is 4.

If a table has 4 Column, its degree is 4.

Primary Key

Primary key ensures uniqueness of a row / tuple.

primary key ensures field is not left NULL.

A table can have max 1 primary key.

Foreign Key

A primary key of another table, it is used to connect a row from a table to another table. It ensures relationship between tables.

A table can have more than one foreign key in a table.

Candidate Key

ATTRIBUTES WHICH ARE CANDIDATE FOR PRIMARY KEY

Alternate Key

CANDIDATE KEY LEFT AFTER CREATING PRIMARY KEY.

Data Definition Language ( DDL )

DDL is used to define structure and constraints of data.

It also defines key constraints, relationships between tables, and other data validation constraints.

Examples:

CREATE DATABASE - Create a new Database

CREATE TABLE - create a new table.

ALTER TABLE - modifies a table.

DROP TABLE - deletes a table.

Data Manipulation Language - DML

Used to insert, modify and delete in a database.

SELECT - EXTARCT DATA FROM A TABLE.

UPDATE - UPDATES DATA IN A TABLE.

DELETE - DELETES DATA FROM A TABLE.

INSERT INTO - INSERTS NEW DATA INTO A TABLE.

MYSQL

Common Data Types :

  • CHAR

  • VARCHAR

  • DATE

  • INTEGER

  • DECIMAL