0% found this document useful (0 votes)
5 views16 pages

Python and SQL Syntax

The document provides an overview of Python programming concepts, including syntax, control structures, functions, string manipulation, data structures, classes, and CSV handling. It also covers SQL commands for database operations and data visualization using matplotlib. The content is structured into chapters, each detailing specific programming elements and their usage with examples.

Uploaded by

justusroopss
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views16 pages

Python and SQL Syntax

The document provides an overview of Python programming concepts, including syntax, control structures, functions, string manipulation, data structures, classes, and CSV handling. It also covers SQL commands for database operations and data visualization using matplotlib. The content is structured into chapters, each detailing specific programming elements and their usage with examples.

Uploaded by

justusroopss
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Class 12 | Computer Science ​ Name: ……………………………………………….. Class: …………… Section: ……..

Python Syntax
Chapter 5 | Python Introduction
print()
print (“string to be displayed as output ” )
print (variable )
print (“String to be displayed as output ”, variable)
print (“String1 ”, variable, “String 2”, variable, “String 3” ……)

input()
variable = input (“prompt string”)

Comments in Python
​ # It is Single line Comment

''' It is multiline comment


which contains more than one line '''

Example of valid identifiers Example of invalid identifiers

Sum, total_marks, regno, num1 12Name, name$, total-mark, continue

Chapter 6 | Control Structures


Conditional Operator
Variable Name = [on_true] if [Test expression] else [on_false]

Simple if statement while loop


​ if <condition>: ​ while <condition>:
statements-block1 statements block 1
if..else statement [else:
​ if <condition>: statements block2]
statements-block 1
else: for loop
statements-block 2 ​ for counter_variable in sequence:
statements-block 1
Nested if..elif...else statement [else: # optional block
​ if <condition-1>: statements-block 2]
statements-block 1
elif <condition-2>: range()
statements-block 2 ​ range (start,stop,[step])
else:
statements-block n start – refers to the initial value
stop – refers to the final value
step – refers to increment value

break continue pass


break continue pass
Chapter 7 | Python Functions
User defined function
​ def <function_name ([parameter1, parameter2…] )>:
<Block of Statements>
return <expression / None>

Passing Parameters in Functions


def function_name (parameter(s) separated by comma):

Anonymous function return statement


lambda [argument(s)]:expression return [expression list]

Built-in and Mathematical functions


Function Description Syntax Example
abs() Returns the absolute value of a abs(x) print(abs(-23.2))
number (integer or float).
Output: 23.2
ord() Returns the ASCII value for a ord(c) print(ord('A'))
given Unicode character.
(Inverse of chr()) Output: 65
chr() Returns the Unicode character chr(i) print(chr(65))
for a given ASCII value. (Inverse
of ord()) Output: A
bin() Returns the binary string bin(i) print(bin(15))
prefixed with "0b" for an integer.
Output: 0b1111
type() Returns the type of object for type(object) print(type(15.2))
the given single object.
Output: <class 'float'>
id() Returns the unique memory id(object) x = 15
address (identity) of an object. print(id(x))

Output: 55978395
min() Returns the minimum value in a min(list) L = [21, 98]
list. print(min(L))

Output: 21
max() Returns the maximum value in a max(list) L = [21, 98]
list. print(max(L))

Output: 98
sum() Returns the sum of values in a sum(list) L = [21, 98]
list. print(sum(L))

Output: 119
format() Returns a formatted string (e.g., format(value, print(format(14, 'b'))
binary, octal, fixed-point format_spec)
notation). Output: 1110
round() Returns the nearest integer to round(number print(round(17.9))
its input, or a number rounded [,ndigits])
to a specified number of digits. Output: 18
Mathematical Functions using math module
floor() Returns the largest integer less [Link](x) x=26.7
than or equal to x. print([Link](x))

Output: 26
ceil() Returns the smallest integer [Link](x) x=26.7
greater than or equal to x. print([Link](x))

Output: 27
sqrt() Returns the square root of x. [Link](x) b=49
(Note: x must be greater than 0). print([Link](b))

Output: 7.0

Chapter 8 | Strings and String Manipulation


replace function
​ string_var.replace(“char1”, “char2”)

String slicing operation Stride when slicing string


​ str[start:end] ​ str[start:end:stride]

Note: Remember that, python takes the end value as n-1

String Formatting Operators


​ (“String to be display with %val1 and %val2” %(val1, val2))

format( ) function
​ (“String to be displayed with {} and {}”.format(var1,var2))

Format Character(s) Usage


%c Character
%d or %i Signed decimal integer
%s String
%u Unsigned decimal integer
%o Octal integer
%x or %X Hexadecimal integer (lower case x refers a-f; upper case X refers A-F)
%e or %E Exponential notation
%f Floating point numbers
%g or %G Short numbers in floating point or exponential notation

Escape Sequence Description


\newline Backslash and newline ignored
\\ Backslash
\' Single quote
\" Double quote
\a ASCII Bell
\b ASCII Backspace
\f ASCII Form feed
\n ASCII Linefeed
\r ASCII Carriage Return
\t ASCII Horizontal Tab
\v ASCII Vertical Tab
\ooo Character with octal value ooo
\xHH Character with hexadecimal value HH

Built-in String functions


Syntax Description (Shortened) Example (Shortened)
count(str, beg, end) Returns the number of str1=”Computer”
non-overlapping occurrences of [Link]('o') -> 1
substring within the given range
(optional). Search is case sensitive.
find(sub[, start, end]) Returns the lowest index of the [Link]('ma') -> 0
first occurrence of substring.
Returns -1 if not found.
len(str) Returns the length (number of len("Corporation") -> 11
characters) of the string.
capitalize() Capitalizes the first character of "city".capitalize()
the string and converts the rest to -> 'City'
lowercase.
center(width, fillchar) Centers the string using a 'Welcome'.center(15, '*')
specified width and fillchar. -> 'Welcome'
isalnum() Returns True if the string contains 'Save Earth'.isalnum()
only letters and digits. -> False
isalpha() Returns True if the string contains 'ABC123'.isalpha()
only letters. -> False
isdigit() Returns True if the string contains 'Save Earth'.isdigit()
only numbers (digits). -> False
lower() Returns a copy of the string with 'SAVE EARTH'.lower()
all letters converted to lowercase. -> 'save earth'
islower() Returns True if all cased 'welcome'.islower()
characters in the string are -> True
lowercase.
isupper() Returns True if all cased 'welcome'.isupper()
characters in the string are -> False
uppercase.
upper() Returns a copy of the string with 'welcome'.upper()
all letters converted to uppercase. -> 'WELCOME'
title() Returns a string in the title case 'education department'.title()
(the first letter of each word is -> 'Education Department'
capitalized).
swapcase() Changes the case of every 'tAmil NaDu'.swapcase()
character (uppercase becomes -> 'TaMIL nAdU'
lowercase, and vice-versa).
ord(char) Returns the ASCII code (integer) ord('A') -> 65
of the given character.
chr(ASCII) Returns the character chr(97) -> 'a'
represented by the given ASCII
code.

Chapter 9 | List, Tuple, Set and Dictionary

Category Operation Syntax


Creating Variable = [element-1, element-2, element-3 ……
element-n]
Accessing Element List_Variable[index of an element]
For Loop for index_var in list: print (index_var)
Changing Element List_Variable [index of an element] = Value to be
changed
Changing Slice List_Variable [index from : index to] = Values to
changed
Adding (append) [Link] (element to be added)
Adding (extend) [Link] ( [elements to be added])
List Adding (insert) [Link] (position index, element)
Delete Particular del List [index of an element] or
Element [Link](element)
Delete Multiple del List [index from : index to]
Delete Entire List del List
Pop by Index [Link](index of an element)
Pop (Last) [Link]()
Clear List [Link]( )
Range Function List_Variable = list (range())
Comprehension List = [ expression for variable in range ]
Creating Empty Tuple_Name = ( )
Creating (n elements) Tuple_Name = (E1, E2, E2 ……. En)
Tuple
Without Parenthesis Tuple_Name = E1, E2, E3 ….. En
Using tuple() Tuple_Name = tuple( [list elements] )
Creating Set_Variable = {E1, E2, E3 …….. En}
Set From List/Tuple Set_Variable = set(list/tuple)
Union set_A | set_B or set_A.union(set_B)
Intersection set_A & set_B or set_A.intersection(set_B)
Difference set_A - set_B or set_A.difference(set_B)
Symm. Difference set_A ^ set_B or set_A.symmetric_difference(set_B)
Creating Dictionary_Name = { Key_1: Value_1, Key_2:Value_2,
…….. Key_n:Value_n }
Creating Empty Dict1 = { }
Comprehension Dict = { expression for variable in sequence [if
condition] }
Dictionary
Adding Elements dictionary_name [key] = value/element
Delete Element del dictionary_name[key]
Clear Elements dictionary_name.clear( )
Delete Entire del dictionary_name

Chapter 10 | Python Classes and Objects

Defining a class Creating Class Methods


class class_name: def method_name(self, [args…]):
statement_1 <statements>
statement_2
………… Constructor / __init__ function
………… def _ _init_ _(self, [args…]):
statement_n <statements>

Creating objects Destructor / __del__ function


Object_name = class_name( ) def __del__(self):
<statements
Accessing Class Members
Object_name . class_member

Chapter 13 | CSV
Category Operation / Method Syntax
[Link]() [Link](fileobject,delimiter,fmtparams)
[Link]() [Link](fileobject,delimiter,fmtparams)
Reading CSV
next() method next(reader_object)
# to skip the first row
[Link]() [Link](fileobject,delimiter,fmtparams)
writerow() [Link](row)
Writing CSV
# writes single row of list
(Lists)
writerows() [Link](rows)
# writes multiple rows of list
[Link]() [Link](fileobject, fieldnames, delimiter,
Writing CSV fmtparams)
(Dicts) writeheader() [Link]()
(writes the fieldnames as the first row)
writerow() [Link](dictionary_row)
writerows() [Link](list_of_dictionaries)
Skip Initial Space csv.register_dialect('myDialect',
skipinitialspace=True)
Custom Delimiter csv.register_dialect('myDialect', delimiter = '|’)
Dialects &
Formatting Custom Quote csv.register_dialect('myDialect', quotechar = '"',
quoting = csv.QUOTE_ALL)
Line Terminator csv.register_dialect('myDialect', lineterminator =
'\n')
itemgetter() [Link](col_no)
Data
Operations sorted() list = sorted(list_to_be_sorted, key =
[Link](col_no), reverse=True/False)

Note: skipinitalspace, custom delimiter and custom quote for [Link](), [Link](),
and [Link]() [Link]() are common for using csv.register_dialect().

Chapter 14 | Importing C++ using Python


Using a function from a module
<module name> . <function name>

[Link]()
[Link] (‘g++ ’ + <variable_name1> +‘ -<mode> ’ + <variable_name2>)

[Link]()
<opts>,<args>=[Link](argv, options, [long_options])

Chapter 15 | Data Manipulation through SQL


Creating connection object Fetching the selected records
connection_object=[Link] [Link]()
t(“database_name.db”) # fetches only one record
[Link]()
Creating cursor object # fetches all the selected
cursor_object = records
connection_object.cursor() [Link](number of
records)
[Link]() command # fetches number of records that
[Link](“SQL Command”) we mentions

To unpack the tuple


print(*tuple,sep="\n")
Chapter 16 | Data Visualization using pyplot

Importing matplotlib
import [Link] as plt

To create plots
i) Line chart
[Link] (x_values, y_values)

[Link] (y_values)
# to create a line plot with one value (default taken as y axis)

ii) Bar chart


[Link] (x_coordinates, height_values)

ii) Pie chart


[Link] (data_variable, labels = label_variable, autopct = "format_string")

SQL Syntax
Chapter 12
Creating table
CREATE TABLE <table-name>
(<column name><data type>[<size>]
(<column name><data type>[<size>]……
);

Creating table with constraints


CREATE TABLE <table-name>
(<column name><data type>[<size>]<column constraint>,
<column name><data type>[<size>]<column constraint>……
<table constraint>(<column name>,[<column name>….]…..
);

INSERT Command
INSERT INTO <table-name> [column-list] VALUES (values);

DELETE Command
DELETE FROM table-name WHERE condition;
# to delete the rows that satisfy the condition

DELETE FROM table-name;


# to delete all the rows

UPDATE Command
UPDATE <table-name> SET column-name = value, column-name = value,… WHERE
condition;

ALTER Command
ALTER TABLE <table-name> ADD <column-name><data type><size>;
# to add a column

ALTER TABLE <table-name> MODIFY<column-name><data type><size>;


# to modify a column

ALTER TABLE <table-name> CHANGE old-column-name new-column-name new column


definition;
# to rename a column

ALTER TABLE <table-name> DROP COLUMN <column-name>;


# to drop or delete a column permanently

TRUNCATE Command
TRUNCATE TABLE table-name;

DROP Command
DROP TABLE table-name;
# to drop a table

DROP DATABASE database-name;


# to drop a database

SELECT Command :
SELECT * FROM<table-name>;
# to select all columns from the table

SELECT <column-list>FROM<table-name>;
# to select required columns from the table

SELECT <column-name>[,<column-name>,….] FROM <table-name>WHERE condition>;


# to select required columns from the table which satisfy certain conditions

ORDER BY Clause
SELECT <column-name>[,<column-name>,….] FROM <table-name>ORDER BY <column1>,
<column2>, …ASC| DESC ;

GROUP BY Clause
SELECT <column-names> FROM <table-name> GROUP BY <column-name> HAVING
condition];

SAVEPOINT Command
SAVEPOINT savepoint_name;

ROLLBACK Command
ROLL BACK TO save point name;

COMMIT Command
COMMIT;
Additional One Marks
(From Points to Remember)

Chapter 1 defined by a set of value and a set of


operations.
●​ Algorithms are expressed using ●​ The definition of ADT only mentions what
statements of a programming language. operations are to be performed but not
●​ Subroutines are small sections of code how these operations will be
that are used to perform a particular task implemented.
that can be used repeatedly. ●​ ADT does not specify how data will be
●​ A function is a unit of code that is often organized in memory and what
defined within a greater code structure. algorithms will be used for implementing
●​ A function contains a set of code that the operations.
works on many kinds of inputs and ●​ Constructors are functions that build the
produces a concrete output. abstract data type.
●​ Definitions are distinct syntactic blocks. ●​ Selectors are functions that retrieve
●​ Parameters are the variables in a information from the data type.
function definition and arguments are ●​ Concrete data types or structures (CDTs)
the values which are passed to a function are direct implementations of a relatively
definition through the function simple concept.
definition. ●​ Abstract Data Types (ADTs) offer a high
●​ When you write the type annotations the level view (and use) of a concept
parentheses are mandatory in the independent of its implementation.
function definition. ●​ A concrete data type is a data type
●​ An interface is a set of actions that an whose representation is known and in
object can do. abstract data type the representation of
●​ Interface just defines what an object can a data type is unknown.
do, but won’t actually do it. ●​ Pair is a compound structure which is
●​ Implementation carries out the made up of list or Tuple.
instructions defined in the interface. ●​ List is constructed by placing expressions
●​ Pure functions are functions which will within square brackets separated by
give exact result when the same commas.
arguments are passed. ●​ The elements of a list can be accessed in
●​ The variables used inside the function two ways: via multiple assignment and the
may cause side effects though the element selection operator.
functions which are not passed with any ●​ Bundling two values together into one can
arguments. In such cases the function is be considered as a pair.
called impure function. ●​ List does not allow to name the various
parts of a multi-item object.

Chapter 2
Chapter 3
●​ Abstract Data Type (ADT) is a type (or
class) for objects whose behavior is ●​ Scope refers to the visibility of variables,
parameters and functions in one part of a
program to another part of the same Chapter 4
program.
●​ The process of binding a variable name ●​ An algorithm is a finite set of
with an object is called mapping. instructions to accomplish a particular
●​ Namespaces are containers for mapping task.
names of variables to objects. ●​ Algorithm consists of step-by-step
●​ The LEGB rule is used to decide the order instructions that are required to
in which the scopes are to be searched for accomplish a task and helps the
scope resolution. programmer to develop the program.
●​ Local scope refers to variables defined in ●​ Program is an expression of algorithm in
the current function. a programming language.
●​ A variable which is declared outside of all ●​ Algorithm analysis deals with the
the functions in a program is known as execution or running time of various
global variable. operations involved.
●​ A function (method) within another ●​ Space complexity of an algorithm is the
function is called nested function. amount of memory required to run to its
●​ A variable declared inside a function completion.
containing another function definition ●​ Big Oh is often used to describe the
creates an enclosed scope, where the worst-case of an algorithm.
inner function can access the outer ●​ Big Omega is used to describe the lower
function's variable. bound which is the best way to solve the
●​ Built-in scope has all the names that are space complexity.
pre-loaded into program scope when we ●​ The Time complexity of an algorithm is
start the compiler or interpreter. given by the number of steps taken by the
●​ The process of subdividing a computer algorithm to complete the process.
program into separate sub-programs is ●​ The efficiency of an algorithm is defined
called modular programming. as the number of computational
●​ Access control is a security technique resources used by the algorithm.
that regulates who or what can view or use ●​ A way of designing algorithm is called
resources in a computing environment. algorithmic strategy.
●​ Public members are accessible from ●​ A space-time or time-memory tradeoff is
outside the class. a way of solving a problem in less time by
●​ Protected members of a class are using more storage space.
accessible from within the class and are ●​ Asymptotic Notations are languages that
also available to its sub-classes. use meaningful statements about time
●​ Private members of a class are denied and space complexity.
access from the outside the class and ●​ Bubble sort is a simple sorting algorithm
handled only from within. that compares each pair of adjacent
●​ Python emulates protected and private items and swaps them if they are in the
behavior by prefixing the name with a unsorted order.
single or double underscore. ●​ The selection sort improves on the bubble
●​ All members in a Python class are public sort by making only one exchange for
by default. every pass through the list.
●​ By default, in C++ and Java, all members ●​ Insertion sort is a simple sorting
are private. algorithm that builds the final sorted array
or list one item at a time and maintains a
sorted sublist.
●​ Dynamic programming is used when the ●​ The three types of flow of control are
solutions to a problem can be viewed as Sequencing, Iteration, and branching or
the result of a sequence of decisions. alternative.
●​ An algorithm that yields ●​ In Python, branching is done using various
expected output for a valid input forms of 'if' structures.
is called an algorithmic solution. ●​ Indentation plays a vital role in Python
●​ A way of designing algorithm programming; it is what groups
is called algorithmic strategy statements without the need to use {}.
●​ An estimation of the time and ●​ Python Interpreter will throw error for all
space complexities of an algorithm indentation errors.
for varying input sizes is called ●​ To accept input at runtime, latest versions
algorithm analysis of Python support input().
●​ print() supports the use of escape
sequence to format the output to the
user’s choice.
●​ range() is used to supply a range of values
Chapter 5
in for loop.
●​ break, continue, and pass act as jump
●​ Python is a general purpose
statements in Python.
programming language created by Guido
●​ pass statement is a null statement, it is
Van Rossum.
generally used as a place holder.
●​ Python shell can be used in two ways, viz.,
interactive mode and Script mode.
●​ Python uses whitespace (spaces and
tabs) to define program blocks.
●​ Whitespace separation is necessary
Chapter 7
between tokens, identifiers or keywords.
●​ Functions are named blocks of code that
●​ A Program needs to interact with end
are designed to do one specific job.
user to accomplish the desired task, this is
●​ Types of Functions are User defined,
done using Input-Output facility.
Built-in, lambda and recursion.
●​ Python breaks each logical line into a
●​ Function blocks begin with the keyword
sequence of elementary lexical
def followed by function name and
components known as tokens.
parenthesis ().
●​ Keywords are special words that are used
●​ A “return” with no arguments is the same
by Python interpreter to recognize the
as return None.
structure of program.
●​ In Python, statements in a block should
begin with indentation.
●​ A block within a block is called nested
block.
Chapter 6
●​ Arguments are used to call a function and
include types like Required, Keyword,
●​ Programs consist of statements which are
Default, and Variable-length.
executed in sequence, to alter the flow
●​ Required arguments are the arguments
we use control statements.
passed to a function in correct positional
●​ A program statement that causes a jump
order.
of control from one part of the program to
another is called control structure or
control statement.
●​ Keyword arguments will invoke the Chapter 9
function after the parameters are
recognized by their parameter names. ●​ A list is known as a sequence data type,
●​ A Python function allows to give default and each value within it is called an
values for parameters in the function element.
definition; we call it as default argument. ●​ The elements of list should be specified
●​ Variable-Length arguments are not within square brackets [].
specified in the function’s definition and ●​ Each element in a list has a unique value
an asterisk (*) is used to define such called index number which begins with
arguments. zero.
●​ Anonymous Function is a function that is ●​ Python allows positive and negative
defined without a name. values as index.
●​ Scope of variable refers to the part of the ●​ Loops are used to access all elements
program where a variable is accessible or from a list.
can be referred to. ●​ The for loop is a suitable loop to access
●​ The value returned by a function used as all the elements of a list one by one.
an argument for another function in a ●​ The append (), extend () and insert ()
nested manner is called composition. functions are used to include more
●​ A function which calls itself is known as elements in a List.
recursion. ●​ The del, remove () and pop () are used to
delete elements from a list.
●​ The range ( ) function is used to generate
a series of values.
Chapter 8 ●​ Tuples consist of a number of values
separated by comma and enclosed within
●​ Strings are immutable, that means once parentheses.
you define string, it cannot be changed ●​ Iterating tuples is faster than list.
during execution. ●​ The tuple ( ) function is also used to
●​ Defining strings within triple quotes also create Tuples from a list.
allows creation of multiline strings. ●​ Creating a Tuple with one element is
●​ In a String, Python allocates an index called a singleton tuple.
value for each character which is known as ●​ A set is a mutable and an unordered
a subscript. collection of elements without
●​ The subscript can be positive or negative duplicates.
integer numbers. ●​ A set is created by placing all the elements
●​ Slice is a substring of a main string. separated by comma within a pair of curly
●​ Stride is a third argument in a slicing brackets.
operation. ●​ A dictionary is a mixed collection of
●​ Escape sequences start with a backslash elements.
and can be interpreted differently.
●​ The format( ) function used with strings is
a very versatile and powerful function
used for formatting strings. Chapter 10
●​ The ‘in’ and ‘not in’ operators can be used
with strings to determine whether a string ●​ Classes and Objects are the key features
is present in another string. of Object Oriented Programming.
●​ In Python, a class is defined by using the ●​ Relational Model represents data as
keyword class. relations or tables.
●​ Variables defined inside a class are called ●​ Network model is similar to Hierarchical
Class Variables and functions are called model but it allows a record to have more
Methods. than one parent.
●​ The process of creating object is called as ●​ ER model consists of entities, attributes
class Instantiation. and relationships.
●​ Constructor is the special function that is ●​ Object model stores data as objects,
automatically executed when an object attributes, methods, classes and
of a class is created. inheritance.
●​ In Python, a special function called init is ●​ Normalization reduces data redundancy
used as Constructor. and improves data integrity.
●​ Destructor is a special method that gets ●​ Database Normalization was proposed by
execution automatically when an object Dr. Edgar F Codd.
exits from the scope. ●​ Relational Algebra is used for modeling
●​ In Python, the __del__() method is used as data stored in relational databases and
destructor. for defining queries on it.
●​ A variable prefixed with double
underscore becomes private in nature.

Chapter 12

Chapter 11 ●​ SQL is a language that helps to create and


operate relational databases.
●​ DBMS is a computer based record ●​ MySQL is a database management
keeping system. system.
●​ Data is unprocessed data which contains ●​ The various components of SQL are DDL,
any character, text, word or number and DML, DQL, TCL, and DCL.
has no meaning. ●​ The DDL provides statements for creation
●​ Information is processed data, and deletion of tables.
organized and formatted. ●​ The DML provides statements to insert,
●​ Examples of RDBMS are mysql, oracle, update and delete data of a table.
sql server, and ibm db2. ●​ The DCL provides authorization
●​ Redundancy means duplication of data in commands to access data.
a database. ●​ The TCL commands are used to manage
●​ Data Consistency means that data values transactions in a database.
are the same at all instances of a ●​ The DQL commands help to generate
database. queries in a database.
●​ Data Integrity is security from ●​ The * is used with the COUNT to include
unauthorized users. the NULL values.
●​ In a database, a table is known as a ●​ The CREATE TABLE command creates a
relation. new table.
●​ A row is called a tuple.
●​ A column is known as an attribute.
●​ Hierarchical model is a simple tree like
structure form with a parent-child
relationship.
Chapter 13 ●​ writerows() method is used to write all
the data at once.
●​ CSV file is a human readable text file ●​ Adding a new row at the end of the file is
where each line has a number of fields, called appending a row.
separated by commas or some other
delimiter.
●​ Excel is a binary file whereas CSV format
is a plain text format. Chapter 14
●​ The two ways to read a CSV file are using
[Link]() function and using ●​ C++ is a compiler based language while
DictReader class. Python is an interpreter based language.
●​ The default mode of csv file in reading ●​ C++ is compiled statically whereas
and writing is text mode. Python is interpreted dynamically.
●​ Binary mode can be used when dealing ●​ A static typed language like C++ requires
with non-text files like image or exe files. the programmer to explicitly tell the
●​ Python has a garbage collector to clean computer what data type each data
up unreferenced objects. value is going to use.
●​ close() method will free up the resources ●​ A dynamic typed language like Python
that were tied with the file. doesn’t require the data type to be given
●​ By default, CSV files should open explicitly; Python manipulates the variable
automatically in Excel. based on the type of value.
●​ The CSV library contains objects and ●​ A scripting language is a programming
other code to read, write, and process language designed for integrating and
data from and to CSV files. communicating with other programming
●​ skipinitialspace is used for removing languages.
whitespaces after the delimiter. ●​ MinGW refers to a set of runtime header
●​ To sort by more than one column, files used in compiling and linking the
[Link]() can be used. code of C, C++ and FORTRAN to be run on
●​ DictReader() class of csv module creates Windows.
an object which maps data to a ●​ The dot (.) operator is used to access the
dictionary. functions of an imported module.
●​ CSV file having custom delimiter is read ●​ sys module provides access to some
with the help of csv.register_dialect(). variables used by the interpreter and to
●​ [Link] and [Link] work with functions that interact with the
list/tuple, while [Link] and interpreter.
[Link] work with dictionary. ●​ OS module in Python provides a way of
●​ [Link] and [Link] take using operating system dependent
additional argument fieldnames that are functionality.
used as dictionary keys. ●​ The getopt module of Python helps you to
●​ The function dict() is used to print the parse (split) command-line options and
data in dictionary format with order. arguments.
●​ The [Link]() function returns a writer
object which converts the user’s data
into delimited strings.
●​ The writerow() function writes one row at Chapter 15
a time.
●​ Users of database can be human users,
other programs or applications.
●​ SQLite is a simple relational database ●​ Aggregate functions are used to do
system, which saves its data in regular operations from the values of the column
data files. and a single value is returned.
●​ Cursor is a control structure used to ●​ COUNT() function returns the number of
traverse and fetch the records of the rows in a table.
database. ●​ AVG() function retrieves the average of a
●​ All the SQL commands will be executed selected column of rows in a table.
using cursor object only. ●​ SUM() function retrieves the sum of a
●​ As data in a table might contain single or selected column of rows in a table.
double quotes, SQL commands in Python ●​ MAX() function returns the largest value
are denoted as triple quoted string. of the selected column.
●​ Select is the most commonly used ●​ MIN() function returns the smallest value
statement in SQL. of the selected column.
●​ The SELECT Statement in SQL is used to ●​ sqlite_master is the master table which
retrieve or fetch data from a table in a holds the key information about your
database. database tables.
●​ The GROUP BY clause groups records into ●​ The path of a file can be either
summary rows. represented as using both / and \ in
●​ The ORDER BY Clause can be used along Python.
with the SELECT statement to sort the
data of specific fields in an ordered way.
●​ Having clause is used to filter data based Chapter 16
on the group functions.
●​ Infographics is the representation of
●​ Where clause cannot be used along with
information in a graphic format.
‘Group by’.
●​ Dashboard is a collection of resources
●​ The WHERE clause can be combined with
assembled to create a single unified visual
AND, OR, and NOT operators.
display.
●​ The ‘AND’ and ‘OR’ operators are used to
●​ Scatter plot is a type of plot that shows the
filter records based on more than one
data as a collection of points.
condition.

“The beautiful thing about learning is that no one can take it away from you."

– B.B. King

You might also like