0% found this document useful (0 votes)
23 views30 pages

DATE

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)
23 views30 pages

DATE

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
You are on page 1/ 30

Ex.

No: 1

CREATING PYTHON PROGRAM THAT ACCEPT A STRING FROM THE USER


AND COUNT THE FREQUENCY OF AN ALPHABET

Aim:
To write a python program to accept a string from the user and count the
frequency of alphabet ‘a’ and ‘c’.

SOURCE CODE

Sample Output:
Ex.No: 2

CREATING A PYTHON PROGRAM TO CHECK WHETHER THE THREE DIGIT


NUMBER IS ARMSTRONG NUMBER OR NOT

Aim:
To write a python program to check whether the three digit number
is Armstrong or not.

SOURCE CODE

Sample Output:
Ex.No: 3

CREATING A PYTHON PROGRAM TO PRINT FIBONACCI SERIES UPTO N TERMS

Aim:
To write a python program to print fibonacci series upto n terms.

SOURCE CODE

Sample Output:

Ex.No: 4
CREATING A PYTHON PROGRAM TO SIMULATE A TRAFFIC LIGHT

Aim:
To write a python program that simulates a traffic light. The
program should consist of the following:

1) user defined function trafficLight() that accepts input from the user, displays an error message
if the user enters anything other than RED, YELLOW, and GREEN. Function light() is called
and following is displayed depending upon return value from light().
i) “STOP, your life is precious” if the value returned by light() is 0.
ii) “Please WAIT, till the light is Green” if the value returned by light() is 1
iii) “GO! Thank you for being patient” if the value returned by light() is 2
2) A user defined function light() that accepts a string as input and returns 0 when the input is
RED, 1 when the input is YELLOW and 2 when the input GREEN. The input should be passed
as an argument.
3) Display “SPEED THRILLS BUT KILLS” after the function trafficLight() is execute.

SOURCE CODE

Sample Output:
Ex.No: 5

CREATING A PYTHON PROGRAM TO IMPLEMENT MATHEMATICAL


FUNCTIONS

Aim:
To write a python program to implement python mathematical
functions to find:

1) To find Square of a Number.


2) To find Log of a Number (i.e. Log10)
3) To find Quad of a Number

SOURCE CODE

Sample Output:
Ex.No: 6

CREATING A PYTHON PROGRAM TO FIND MEAN AND MEDIAN OF GIVEN DATA

Aim:
To write a python program to calculate the average amount obtained
and median of the data below. Consider the amount of donations
received by a charitable organization given as under:
Donations=[100,60,70,900,100,200,500,500,503,600,1000,1200]

SOURCE CODE

Sample Output:

Ex.No: 7

CREATING A PYTHON PROGRAM TO READ A TEXT FILE LINE BY LINE AND


DISPLAY THOSE WORDS ENDING WITH ‘E’

Aim:
To write a python program to read data from the file “Story.txt” and display those
words which are ending with ‘e’.

SOURCE CODE

Sample Output:

Ex.No: 8

CREATING A PYTHON PROGRAM TO READ A TEXT FILE AND DISPLAY THOSE


WORDS, WHICH ARE LESS THAN 4 CHARACTERS

Aim:
To write a python program to read data from a text file Poem.txt and display those
words which are less than 4 characters.

SOURCE CODE
Sample Output:

Ex.No: 9

CREATING A PYTHON PROGRAM TO REPLACE ALL THE CAPITAL LETTERS WITH


THEIR RESPECTIVE SMALL LETTERS IN THE SAME FILE.

Aim:
To write a Python program to replace all the Capital letters with their
respective small letters in the same file.

SOURCE CODE
Sample Output:

Ex.No: 10

CREATING A PYTHON PROGRAM TO DISPLAY ALL THE RECORDS IN A FILE


ALONG WITH LINE/RECORD NUMBER

Aim:
To write a Python program to display all the records in a file along with
line/record number.

SOURCE CODE
Sample Output:

Ex.No: 11

CREATING A PYTHON PROGRAM TO CREATE RECORDS IN BINARY FILE

Aim:
To write a Python program to add employees in a binary file “employee.dat”, created
using dictionary object having keys: (empcode, name, and salary)
SOURCE CODE

Sample Output:

Ex.No: 12
CREATING A PYTHON PROGRAM TO DISPLAY RECORDS IN BINARY FILE

Aim:
To write a Python program to display all employee records whose salary is more
than or equal to 30000

SOURCE CODE

Sample Output:

Ex.No: 13
CREATING A PYTHON PROGRAM TO CREATE AND SEARCH VOTERS IN CSV FILE

Aim:
To write a Python program to write and read data from a CSV File consisting
Voter_ID, VoterName, VoterAge Write a function to display those records where
voter age is more than 65.

SOURCE CODE

Sample Output:
Ex.No: 14

CREATING A PYTHON PROGRAM TO IMPLEMENT STACK OPERATIONS

Aim:
To write a Python program to implement Stack using a list data-structure.

SOURCE CODE
Sample Output:
Ex.No: 15

CREATING A PYTHON PROGRAM TO IMPLEMENT STACK OPERATIONS

Aim:
Write separate user defined functions for the following:
i) PUSH(N)- This function accepts a list of names, Nas parameter. it then
pushes only those names in the stack named OnlyA which contain the letter ‘A’.

ii) POPA(OnlyA)- This function pops each name from the stack OnlyA and
displays it.

SOURCE CODE
Sample Output:
Ex.No: 16

CREATING A PYTHON PROGRAM TO INTEGRATE MYSQL WITH PYTHON


(CREATING DATABASE AND TABLE)

Aim:
To write a Python Program to integrate MYSQL with Python by creating database
Employees and table Emp.

SOURCE CODE

Sample Output:

Ex.No: 17

CREATING A PYTHON PROGRAM TO INTEGRATE MYSQL WITH PYTHON


(INSERTING RECORDS AND DISPLAYING RECORDS)

Aim:
To write a Python Program to integrate MYSQL with Python by inserting records to
Emp table and display the records.

SOURCE CODE

Sample Output:
Ex.No: 18

CREATING A PYTHON PROGRAM TO INTEGRATE MYSQL WITH PYTHON


(SEARCHING AND DISPLAYING RECORDS)

Aim:
To write a Python Program to integrate MYSQL with Python to search an Employee
using EMPID and display the record if present in already existing table EMP, if not
display the appropriate message.

SOURCE CODE
Sample Output:

Ex.No: 19

CREATING A PYTHON PROGRAM TO INTEGRATE MYSQL WITH PYTHON


(UPDATING RECORDS)

Aim:
To write a Python Program to integrate MYSQL with Python to search an Employee
using EMPID and update the record if present in already existing table EMP, if not
display the appropriate message.

SOURCE CODE

Sample Output:
Ex.No: 20

SQL COMMANDS EXERCISE-1


Aim:
To display Wno,name,gender from table worker in
descending order
Ex.No: 21

SQL COMMANDS EXERCISE-2


Aim:
To select employees whose age is less than 25
Ex.No: 22

SQL COMMANDS EXERCISE-3

Aim:
To display name,department, city for all workers from given
tables
Ex.No: 23

SQL COMMANDS EXERCISE-4


Aim:
TO display all the records from the table sales;
Ex.No: 24

SQL COMMANDS EXERCISE-5

Aim:
Display all the details of teacher including gender and
designation from given tables

You might also like