0% found this document useful (0 votes)
2 views

Notes-chapter1-python-class 9

The document covers basic concepts in Python programming, including comments, data types, decision making, loops, and functions. It also introduces MySQL, explaining databases, DBMS, ER models, and SQL statement types such as DDL, DML, and DCL. Key examples and syntax for each concept are provided to aid understanding.

Uploaded by

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

Notes-chapter1-python-class 9

The document covers basic concepts in Python programming, including comments, data types, decision making, loops, and functions. It also introduces MySQL, explaining databases, DBMS, ER models, and SQL statement types such as DDL, DML, and DCL. Key examples and syntax for each concept are provided to aid understanding.

Uploaded by

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

Notes

Class 9

Computer-Chapter 1

1. Comments in python

Comments are human readable description in

programs.There are two types of comments in python

• Single line comment


Single line comments written using ‘#’

symbol.Eg: #this is a single line comment in

python.

• Multiline comment

multiline comments are enclosed inside Triple

quotesEg:”””These are multi line comments”””

2. Python datatypes

Python has five basic datatypes:

1) Numeric
2) Boolean
3) Set
4) Mapping
5) Sequence

3. Numeric

1) Int-Whole numbers
2) Float-(floating point real values)
3) Complex-(mixed values of characters and numbers)
4. List

A list contains items separated by commas and enclosed within square brackets([

]).Items in a list can be of different data types.

+ sign in is used for joining two lists

*Sign is used for repeating two lists.


Example
list1=[1,2,3,4,5,6]

5. tuple

A tuple contains items separated by commas and enclosed within brackets(). Tuples are

sequences just like lists but cannot changed

Eg:tuple1=(1,2,3,4,5)

Decision making in python

There are two statements for making decision in python

• If
• If else
• Nested if

Syntax:

IF CONDITION

If condition:

Statement……

IF ELSE CONDITION

If condition:

Statement…

Else:

Statement…

NESTED IF CONDITION

If statement inside an if statementIf(condition

1):

If(condition 2):

Statement..

ELIF STATEMENT

Allows to check multiple condition

Eg: If expression 1:

statement(s)

Elif expression

Statement(s)
Elif expression 3:

Statement(s)Elif expression

Statement(s)

LOOPS

A loop is a piece of code which allows you to repeat a code more than once .without writing it more than once

There are two loops in python

• While loops
• For loop

For loop

For loop is used when you know how many times you have to repeat a taskEg:

Example in text book page No:12

While loop

While loop is used when we have to execute a code until a condition is true Example in

text book page no:11

Loop control statements


There are three control statements in python
• Break statement
• Continue statement
• Pass statement
Break statement
Break statement ends the loop and passes control to the line immediately after the loop.
Eg:

Continue statement

Continue statement passes control to the beginning of the loop

Eg:
Pass Statement
When the pass statement is executed, nothing happens, but you avoid getting an error when empty code is not
allowed.

Empty code is not allowed in loops, function definitions, class definitions, or in if statements.

Eg:

Functions
A function is an organized and reusable code used to perform specific task.

A function has two parts


• Define a function
To define a function or create a function we use def keyword

Example:def Functionname():

• Calling a function
For using a function we have to call the function inside the program using function name.

Example:functionname();

Return statement

Return statement is used to exit from a function.

Example:Return [expression]

Types of variables

There are two types of variables

• Global variable
• Local variables

Global variable:-The variable which is created outside the function is called as global variable
Local variables:-The variables which created inside the function is called as local variable.

Chapter 2
MySQL

Database
A collection of data in an organized way for future reference is called as database.And database used in applications
like, Instagram, facebook, google ,amazon,etc.
DBMS
Full form is database management system. also called as Relational database Management system(RDBMS) .
It is a middleware between user and database.

ER -Model
Full form of ER model is Entity Relationship model .in this model data is stored as tables.
• Entity-It it real world object
• Attribute-It is the characteristics of an entity
• Relation-A relation is a two dimensional table
• Relationship-It is the connection between two tables

In a table there are rows and columns Rows are also called as Tuples and columns are also called as Attributes

MYSQL
It is the most used RDBMS

SQL-Structured Query Language-the language used to manage RDBMS

TYPES OF SQL STATEMENTS

Three types are there


• Data Definition Language(DDL)
• Data Manipulation Language(DML)
• Data Control Language(DCL)

DDL Commands are


1. CREATE-used to create a table
2. ALTER-Used to modify a table
3. DROP-delete tables
4. TRUNCATE -set the database to initial condition

Example for creating a table


To see the table
Describe tablename;
Example:
Describe person;
DML Commands
DML commands are also called as CRUD operations And they are
1. C-Create-INSERT command is used for creating a table
2. R-Read- SELECT command is used for Reading a table
3. U-update-Update Command is used for updating a table
4. D-delete-Delete command is used for removing a table

Syntax for inserting data to a table

DCL Commands
1. GRANT
2. REVOKE

You might also like