Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
computer science file (python)
1. I.T
Practical
file
2020-
2021
Python is an interpreted, high-level, general-
purpose programming language. Created by
Guido van Rossum and first released in 1991,
Python's design philosophy emphasizes code
readability with its notable use of significant
whitespace. Its language constructs and object-
oriented approach aim to help programmers
write clear, logical code for small and large-scale
projects.
Submitted by-
AASHISH
(X11commerce)
Submitted to –
Aruna Ma’am
2. I would like to express a deep sense
of thanks and gratitude to my
computer science teacher Mrs. Aruna
Ahuja for guiding me immensely
through the course of my project. Her
constructive advice and constant
motivation have been responsible for
the successful completion of my
project.
My sincere thanks to my parents for
their motivation and support. I must
thanks my classmates for their
timely help and support for
compilation of this project.
4. This is to certify that Aashish
Kumar of Class XII- Commerce . Has
completed the practical file under my
supervision . The report is the result
of his efforts and endeavours. He has
taken proper care and shown at most
sincerity in completion of this project.
I certify that this project is up to
my expectation & as per guidelines
issued by CBSE.
6. TABLE OF CONTENTS
If statement _________________________________________ #
Program 1- if the number is positive, we print an apporiate message #
Program 2 -To print message if condition matches________________#
Program 3 -To see wether the no. is less than 200 or bigger than 200
Program 4 -To find the greater no.
If.else statement ______________________________________ #
Program 5 -To find will shop will give discount __________________#
Program 6 -To find greater no. _______________________________#
Program 7 -To find the year is leap year or not
Program 8- To check wether the person is eligble to donate blood ___#
The elif statement ____________________________________ #
Program 9- To check if the no. is positive or negative or zero ______#
Program 10- To enter temp and see wether it’s ok for going out or no#
Program 11 -To check wether no. is uppercase or lower case _______#
The nested if ________________________________________ #
Program 12- To check if the no. is positive or negative ____________#
For Loop ___________________________________________ #
Program 13 -To display no. in range __________________________#
Program 14 -To factorial of no. _______________________________#
Program 15 -To find factorial ________________________________#
Program 16 -To find sum of even and odd no. ___________________#
Program 17 -To find no. is even or odd no. ______________________#
Nested for loop ______________________________________ #
Program 18 -To print no. multiple times ________________________#
Program 19 -To print a specific pattern _______________________#
While loop _________________________________________ #
Program 20- To print no. from 1 till 10 using gap of 3 ____________#
Program 21 -To print 1 infinte _______________________________#
Program 22 -To print table of 9 _______________________________#
7. While else ___________________________________________ #
Program 23- To accept no.from user and diplay the result ________#
Program 24 -To check if the no. is palindrome ___________________#
While nested _________________________________________ #
Program 25 To print specific pattern___________________________#
Program 26 To find the prime numbers from 2 to 100 _________#
List ________________________________________________ #
Program 27- add 5 in all odd values and 10 in all evevn values of the list#
Program 28- display unique and duplictae items of a given list______#
Program 29-To exchange half of the elements of list with second half
elements of list _____________________________________________#
Strnig ______________________________________________ #
Program 30- display square of a element if it is an integer and changes
the case if element is a string __________________________________#
Program 31- reads a string and then prints a string that capitalizes every
other letter in the string ______________________________________#
Program 32 to check whether the string is a palindrome or not _____#
Program 33- To count the no. of vowels in the string ______________#
Program 34-To remove vowels from a string _ ___________________#
Tuples and dictionary__________________________________ #
Program 35- To input 'n' names and phone numbers to store it in a
dictionary and printthe phone number of a paarticular name_______#
Program 36- To input names of 'n' countries andf thier capital and
currency, store it in a dictionary in tacbular form. also search and dispaly
for a particular country.______________________________________#
Program 37-To input names of 'n'employes and thier salary details like
basic salary, house rent anad conveyamcr allowance. cal. total salary of
each employee and display. ___________________________________#
SQL _______________________________________________ #
1 Query-Command for creating database________________________#
2 QueryCommand for using the database________________________#
3 Query-Command for creating table___________________________#
4 Query-Command for showing the structure of table_____________#
8. 5 Query-Command to show table present in databse _______________#
6 Query-Command for inserting data into a table__________________#
7 Query-Command to view the contents of the table________________#
8 Query-Command for retrieve data_____________________________#
9 QueryCommand for using keyword DISTINCT__________________#
10 Query-Command for using WHERE clause____________________#
11 Query-Command for using ORDER BY clause_________________#
12 Query-Command for using UPDATE_________________________#
13 Query-Command for using ALTER(to modify structureof table) __#
14 Query-Command for using LIKE operator_____________________#
15 Query-Command for using aggregate functions_________________#
16 Query-Command for using GROUP BY with COUNT __________#
17 Query-Command for using Group By with Order By____________#
18 Query-Command for equi-join of tables _______________________#
19 Query-Command to retrieve data from two tables ______________#
20 Query-Command for using Group By clause in join_____________#
21 Query-Command for using where clause and group by__________#
22 Query-Command to delete a column__________________________#
23 Query-Command for using logical operators __________________#
24 Query-Command for using arithmetic operators_______________#
25 Query-Command for select data in range _____________________#
26 Query-Command for using In condition_______________________#
27 Query-Command to change data type of an existing column______#
28 Query-Command to delete table______________________________#
29 Query-- Command to join table using Cross Join (Cartesian product)#
30 Query- Command to join table using Equi join__________________#
31 Query- Command to join table using Natural join_______________#
WORKING WITH FUNCTION__________________________________#
Program -38-Passing dictionary to function with key and value, and
update value at that key in dictionary___________________________#
Program -39-Creating a login program with the help of passing tuple to
function____________________________________________________#
9. Program -40-Passing list to function to calculate sum and average of all
numbers and return it in the form of tuple______________________#
Program -41-Passing list to function, and just double each value____#
BINERY FILE HANDLING____________________________________#
Program 44-Program to search for name in binary file and display record
number___________________________________________________#
Program -45-Program to delete name from binary file____________#
Progam -46-Program to update name in Binary File______________#
Program -47-Finding Number of Record in Binary File___________#
Program -48-Deleting Employee Record________________________#
COMMA SEPARATED VALUE_________________________________#
Prgram -49-Program to Counting number of records_____________#
Program -50-Program to get Sum of Salary and counting employee
getting more than 7000______________________________________#
Program -51-Program to Write data to CSV file_________________#
FILE HANDLING____________________________________________#
Program -52-Progam to read text file using read()________________#
Program -53-wap to add 2 more students of a class in a previously
created file_________________________________________________#
Program -54-wap to display contents of a previously created file____#
Program -55-wap to display the size of files in bytes_______________#
Program -56-wap to get informaion of students of a class and store these
details in a file______________________________________________#
USING PYTHON LIBRARIES___________________________________#
Program 57-Program to convert numbr to octal and hexadecimal____#
Program -58-Program to suare of no. using math module__________#
INTERFACE PYTHON WITH MYSQL___________________________#
Program-61-Program to establish connection with MySQL_________#
Program-62-Program to get all data using fetchall()______________#
Program -63-Program to get only one record using fetchone()______#
Program -64-Program to get multiple records using fetchmany()____#
Program -65-Concatenating variable with query__________________#
Program -66-String template with %s formatting_________________#
10. Program -67-String template with {} and format()_________________#
Program -68-Program to insert data____________________________#
Program -69-Program to Update record_________________________#
Stack________________________________________________________#
Program -71-wap to demonstrate operation on a stack _____________#
Queue_______________________________________________________#
Program -71-wap to demonstrate operations on queue_____________#
11. IF Statement -
An if statement is a
programming conditional
statement that, if proved
true, performs a function or
displays information. Below is
a general example of an if
statement, not specific to
any particular programming
language.
12. Program No.-1 – If the number is positive, we print
an appropriate message
INPUT
OUTPUT
13.
14. Program No.-2 – To print message if condition
matches
INPUT
OUTPUT
15. Program No.-3- To see whether the no. Is less than
200 or bigger than 200
INPUT
18. and will execute body of if only
when test condition is True.
If the condition is False, body
of else is executed.
Indentation is used to
separate the blocks.
Program No.-5- to find will shop will give discount
INPUT
22. Program No.-8 –To check whether the person is
eligible to donate blood
INPUT
OUTPUT
23. The elif statement –
The elif statement allows
you to check multiple
expressions for TRUE and
execute a block of code as
soon as one of the conditions
evaluates to TRUE. Similar
to the else, the elif
statement is optional.
24. Program No.-9- To check if the no. Is positive or
negative or zero
INPUT
OUTPUT
25. Program No.10- To enter temp and see whether
it’s ok for going outside
INPUT
OUTPUT
26. Program No.11- To check whether no. Is
uppercase or lower case
INPUT
27. OUTPUT
The nested if –
The nested if... else
statement allows you to
check for multiple test
expressions and execute
28. different code for more then
two conditions. we can have
levels of nesting inside if...else
statement
Program No.12-To check if no. Is positive or
negative
INPUT
29. OUTPUT
For loop-
If a sequence contains an
expression list, it is evaluated
first. Then, the first item in
the sequence is assigned to
30. the iterating variable
iterating var. Next, the
statements block is executed.
Each item in the list is
assigned to iterating var, and
the statement(s) block is
executed until the entire
sequence is exhausted.
Program No.13-To display no. in range
44. While else –
If the else statement is
used with a for loop,
the else statement is
executed when the loop has
exhausted iterating the
list.
If the else statement is
used with a while loop,
the else statement is
executed when the
condition becomes false.
45. Program No.23 –To accept no. From user and
display the result
INPUT
OUTPUT
51. In Python programming, a list is created by
placing all the items (elements) inside a square
bracket [], separated by commas. It can have
any number of items and they may be of
different types (integer, float, string etc.). Also,
a list can even have another list as an item.
This is called nested list
52. Program No.27- add 5 in all odd values and 10 in all
even values of the list
INPUT
OUTPUT
54. Program No.29-To exchange half of the elements of list
with second half elements of list
INPUT
OUTPUT
55. Program No.30- o display square of an element if it is
an integer and changes the case if element is a string
INPUT
56. OUTPUT
String-
A string is a sequence of characters.
A character is simply a symbol. For example, the
English language has 26 characters.
Computers do not deal with characters; they
deal with numbers (binary). Even though you
may see characters on your screen, internally it
is stored and manipulated as a combination of
0's and 1's.
57. This conversion of character to a number is
called encoding, and the reverse process is
decoding. ASCII and Unicode are some of the
popular encoding used.
In Python, string is a sequence of Unicode
character. Unicode was introduced to include
every character in all languages and bring
uniformity in encoding.
Program No.31- reads a string and then prints a string
that capitalizes every other letter in the string
INPUT
62. Tuples and Dictionary
Tuples-
Python tuple is a collection type data structure which is
immutable by design and holds a sequence of heterogeneous
elements. It functions almost like a Python list but with the
following distinctions.
Tuples store a fixed set of elements and don’t allow changes
whereas the list has the provision to update its content.
The list uses square brackets for opening and closing
whereas, and a tuple has got parentheses for the enclosure.
Dictionary-
Dictionary in Python is a scrambled collection of objects. Unlike
other data types such as a list or a set which has a single value
field, the dictionary type stores a key along with its value.
The keys pair with values using a colon (:) while the
commas work as a separator for the elements. Also, the
entire dictionary object uses curly braces to enclose itself.
63. Program No.35- To input 'n' names and phone
numbers to store it in a dictionary and print the phone
number of a particular name
INPUT
OUTPUT
64. Program No.36- To input names of 'n' countries and
their capital and currency, store it in a dictionary in
tabular form. also search and display for a particular
country.
INPUT
OUTPUT
Program No.26- To find the prime no. from 2 to 100
67. Program No.37-To input names of 'employees and their
salary details like basic salary, house rent and
conveyance allowance. cal. total salary of each
employee and display
INPUT
OUTPUT
68. SQL
Structured Query language
is a domain-specific language used in programming and designed
for managing data held in a relational database management
system (RDBMS), or for stream processing in a relational data
stream management system (RDSMS). It is particularly useful
in handling structured data, i.e. data incorporating relations
among entities and variables.
SQL offers two main advantages over older read–write APIs
such as ISAM or VSAM. Firstly, it introduced the concept of
accessing many records with one single command. Secondly, it
eliminates the need to specify how to reach a record, e.g. with or
without an index.
69. Originally based upon relational algebra and tuple relational
calculus, SQL consists of many types of statements, which may
be informally classed as sublanguages, commonly: a data query
language (DQL),[a] a data definition language (DDL),a data
control language (DCL), and a data manipulation language (DML).
The scope of SQL includes data query, data manipulation (insert,
update and delete), data definition (schema creation and
modification), and data access control. Although SQL is essentially
a declarative language (4GL), it includes also procedural
elements.
70. 1 Query-Command for creating database
2 Query Command for using the database
3 Query-Command for creating table
4 Query-Command for showing the structure of table
5 Query-Command to show table present in database
71. 6 Query-Command for inserting data into a table
7 Query-Command to view the contents of the table
8 Query-Command for retrieve data
72. 9 Query Command for using keyword DISTINCT
10 Query-Command for using WHERE clause
11 Query-Command for using ORDER BY clause
12 Query-Command for using UPDATE
73. 13 Query-Command for using ALTER (to modify structure of table)
14 Query-Command for using LIKE operator
15 Query-Command for using aggregate functions
16 Query-Command for using GROUP BY with COUNT
17 Query-Command for using Group by with Order By
74. 18 Query-Command for equi-join of tables
19 Query-Command to retrieve data from two tables
20 Query-Command for using Group By clause in join
21 Query-Command for using where clause and group by
22 Query-Command to delete a column
75. 23 Query-Command for using logical operators
24 Query-Command for using arithmetic operators
25 Query-Command for select data in range
26 Query-Command for using in condition
76. 27 Query-Command to change data type of an existing column
28 Query-Command to delete table
29 Query- Command to join table using Cross Join
(Cartesian product)
77. 30 Query- Command to join table using Equi join
31 Query- Command to join table using Natural join
78. WORKING
WITH
FUNCTION-
Large programs are often difficult to manage,
thus large programs are divided into smaller
units known as functions.
It is simply a group of statements under any
name i.e. function name and can be invoked (call)
from other part of program.
Take an example of School Management
Software, now this software will contain
various tasks like Registering student, Fee
collection, Library book issue, TC generation,
79. Result Declaration etc. In this case we have to
create different functions for each task to
manage the software development.
88. BINERY FILE
HANDLING
It stores the information in the same
format as in the memory i.e. data is stored
according to its data type so no translation
occurs.
In binary file there is no delimiter for a new
line
Binary files are faster and easier for a
program to read and write than text files.
89. Data in binary files cannot be directly read,
it can be read only through python program
for the same.
Program No.-44
Program to search for name in binary file
and display record number
INPUT
95. COMMA SEPARATEDVALUE
CSV is a simple file format used to store
tabular data, such as a spreadsheet or
database.
Files in the CSV format can be imported to
and exported from programs that store
data in tables, such as Microsoft Excel or
OpenOffice Calc.
CSV stands for "comma-separated values“.
A comma-separated values file is a delimited
text file that uses a comma to separate
values.
record consists of one or more fields,
96. separated by commas. The use of the
comma as a field separator is the source of
the name for this file format
Prgram No.-49
Program to Counting number of records
INPUT
OUTPUT
100. HANDLING
Text file stores information in ASCII OR UNICODE
character. In text file everything will be stored as a
character for example if data is “computer” then it
will take 8 bytes and if the data is floating value
like 11237.9876 it will take 10 bytes.
In text file each like is terminated by special
character called EOL. In text file some translation
takes place when this EOL character is read or
written. In python EOL is ‘n’ or ‘r’ or combination
of both
105. Program No.-56
wap to get informaion of students of a
class and store these details in a file
INPUT
OUTPUT
106. USING PYTHON
LIBRARIES
As our program become larger and more complex
the need to organize our code becomes greater. We
have already learnt in Function chapter that large
and complex program should be divided into
functions that perform a specific task. As we
write more and more functions in a program, we
should consider organizing of functions by storing
them in modules
A module is simply a file that contains Python code.
When we break a program into modules, each
modules should contain functions that perform
related tasks.
Commonly used modules that contains source code
for generic needs are called Libraries.
110. INTERFACE PYTHON
WITH MYSQL
Before we connect python program with any database
like MySQL we need to build a bridge to connect
Python and MySQL.
To build this bridge so that data can travel both ways
we need a connector called “mysql.connector”.
We can install “mysql.connector” by using following
methods:
At command prompt (Administrator login)
Type “pip install mysql.connector” and press enter
n
“https://dev.mysql.com/downloads/connector/python/”
and download connector as per OS and Python version
121. STACK
A stack is a collection of data
items that can be accessed at only
one end, called top.
Items can be inserted and deleted
in a stack only at the top.
The last item inserted in a stack
is the first one to be deleted.
122. Therefore, a stack is called a
Last-In-first-Out (LIFO) data
structure.
2 mains operations on Stack is
PUSH &POP
PUSH means inserting new item
at top and POP means deleting item
from top.
Program No.-71
Write a menu based program to demonstrate
operation on a stack
INPUT
125. QUEUE
Queue is a linear list which follows
FIFO approach.
Queue allows addition of element only
at one end called REAR (end of list) &
Deletion of element only from FRONT end
(beginning of list).
126. The operation of addition and deletion
is known as Enqueue and Dequeue
respectively.
Applications of Queue:
oPrinter Spooling
oCPU Scheduling
oMail Service
oKeyboard Buffering
oElevator
Program No.-71
Write a menu based program to demonstrate
operations on queue
INPUT