EX.
NO: 1
MENU DRIVEN PROGRAM TO PERFORM ARITHMETIC OPERATIONS
Alogrithm:
Step 1: Start the program
Step2: Display the various arithmetic operations
Step3: Get the input from the user
Step3: Check the choices to evaluate the arithmetic operations
Step4: Stop the program
EX.NO: 2
CREATING A PYTHON PROGRAM TO DISPLAY FIBONACCI SERIES
Algorithm:
Step 1: Start the program
Step2: Create two variables and initialize them with 0 and 1
Step3: Get the input from the user
Step4: Check the conditions and print the values
Step5: Access the range of values from the for loop
Step6: Update the values into respective variables in sequence order
Step6: Stop the program
EX.NO: 3
CREATING A MENU DRIVEN PROGRAM TO FIND FACTORIAL AND SUM OF LIST OF
NUMBERS USING FUNCTION.
Algorithm:
Step1: Start the program
Step2: Define a factorial () function and sum_ List () function
Step3: Get the input from the user
Step4: Check the condition whether true or false
Step6: If the condition is true pass the value to factorial () function and execute the body of the
statements
Step7: If the condition is False loop will forwards elif condition and execute the body of the statements.
Step8: Stop the program
EX.NO: 4
CREATING A PYTHON PROGRAM TO IMPLEMENT RETURNING VALUE(S)
FROM FUNCTION
Algorithm:
Step1:Start the program
Step2: Define a check() function
Step3: Get input from the user
Step3:Pass the arguments value to the called check() function
Step4:Check the condition whether it is true/false and return the value
Step5:Print the value
Step6:Stop the program
EX.NO:5
CREATING A PYTHON PROGRAM TO IMPLEMENT MATHEMATICAL FUNCTIONS
Algorithm:
Step1: Start the program
Step2: Import the math module
Step3: Define a square (),log() and quad() function
Step4: Pass values to the called function and return the value
Step5: Stop the program
EX.NO:6
CREATING A PYTHON PROGRAM TO GENERATE RANDOM NUMBER BETWEEN 1 TO
6
Algorithm:
Step1:Start the program
Step2:Import random module
Step3:Check the condition whether true or false
Step4:Get input from the user
Step5:Find out the random integers between 1 to 6
Step6:Check the condition whether the condition is true/false
Step7:If the condition is true print the number else if the condition is false break the program
Step8:Stop the program
EX.NO:7
CREATING A PYTHON PROGRAM TO READ A TEXT FILE LINE BY LINE AND
DISPLAY EACH WORD SEPARATED BY '#'
Algorithm:
Step1:Start the program
Step2:Open the document and set access mode
Step3:Read the number of lines by using the readlines() function
Step4:Access lines from the variable name contents
Step5:Split the words from the line by using the split() function
Step6:Display the each word separated by # sign
Step7:Close the document by using the file handle name
Step8:Stop the program
EX.NO:8
CREATING A PYTHON PROGRAM TO READ A TEXT FILE AND DISPLAY THE
NUMBER OF VOWELS/CONSONANTS/LOWER CASE/ UPPER CASE CHARACTERS
Algorithm:
Step1:Start the program
Step2:Open the document and set access mode
Step3:Read the document by using the read() function
Step4:Initial value assigned to the respective variable names
Step5:Access the characters from the variable names
Step6:Check the characters whether it is vowels,consonants,uppercase and lowercase
Step7:Close the document by using the file handle name
Step8:Print the total number of vowels,consonants,uppercase and lowercase
Step9:Stop the program
EX.NO:9
CREATING PYTHON PROGRAM TO DISPLAY SHORT WORDS FROM A TEXT FILE
Algorithm:
Step1:Start the program
Step2:Define the disp() function name
Step3:Open the document through file handle name
Step4:Read the entire document by using read() function
Step5:Split the words from read lines
Step6:Access the words from the variable name
Step7:Identify the size of the words and check the condition
Step8:Print the number of characters
Step9:Close the document by using file handle name
Step10:Stop the program
Ex.No :10
CREATING A PYTHON PROGRAM TO COPY PARTICULAR LINES OF A TEXT FILE
INTO AN ANOTHER TEXT FILE
Algorithm:
Step1: Start the program
Step2: Open the document and set access mode through file handle name
Step3: Read all the lines from the document by using readlines() function
Step4: Access the lines from the variable
Step5: Check the conditions whether any one of the condition is fulfilled
Step6: Write a lines to the second document
Step7: Print the output comments
Step8: close the both documents through file handle name
Ex.No :11
CREATING A PYTHON PROGRAM TO CREATE AND SEARCH RECORDS IN BINARY
FILE
Aim:
To create a python program to create and search records in binary file.
Algorithm:
Step1: Start the program
Step2: Import the pickle module in header statement
Step3: Define a function in the name of create() and search() in prior
Step4: Call the create() function
Step5: Open the document and set access mode through file handle name
Step6: Check the condition and execute the body of the statements
Step7: Obtain the input values from the user through input statements
Step8: Update the input values into list
Step9: Write the list of elements into documents by using the dump () function
Step10: Obtain the input values from the user through input statements
Step11: Close the documents through file handle name.
Step12: Call the search () function
Step13: Obtain the input values from the user through input statements
Step14: Create a try and except block to check the condition
Step15: If the condition becomes True, the body of the statement will be executed respectively, whereas
if the condition becomes false control will forward to another block
Step16: Stop the program
EX.NO: 12
CREATING A PYTHON PROGRAM TO CREATE AND UPDATE/MODIFY
RECORDS IN BINARY FILE
Aim:
To create a python program to create and update/modify records in binary file
Algorithm:
Step1: Start the program
Step2: Import the pickle module in header statement
Step3: Define a function in the name of create() and update() in prior
Step4: Call the create() function
Step5: Open the document and set access mode through file handle name
Step6: Check the condition and execute the body of the statements
Step7: Obtain the input values from the user through input statements
Step8: Update the input values into list
Step9: Write the list of elements into documents by using the dump () function
Step10: Obtain the input values from the user through input statements
Step11: Close the documents through file handle name.
Step12: Call the update () function
Step13: Obtain the input values from the user through input statements
Step14: Create a try and except block to check the condition
Step15: If the condition becomes True, the body of the statement will be executed respectively, whereas
if the condition becomes false control will forward to another block
Step16: Stop the program
EX.NO: 13
CREATING A PYTHON PROGRAM TO CREATE AND SEARCH
EMPLOYEE’S RECORD IN CSV FILE.
Aim:
To create a python program to create and search employee’s record in csv file.
Algorithm:
Step1: Start the program
Step2: Import the csv module in header statement
Step3: Define a function in the name of create() and search() in prior
Step4: Call the create() function
Step5: Open the document and set access mode through file handle name
Step6: Check the condition and execute the body of the statements
Step7: Obtain the input values from the user through input statements
Step8: Update the input values into list
Step9: Write the list of elements into documents by using the dump () function
Step10: Obtain the input values from the user through input statements
Step11: Close the documents through file handle name.
Step12: Call the search() function
Step13: Obtain the input values from the user through input statements
Step14: Create a if condition
Step15: If the condition becomes True, the body of the statement will be executed respectively,
Step16: Stop the program
EX.NO: 14
CREATING A PYTHON PROGRAM TO IMPLEMENT STACK
OPERATIONS(LIST)
Aim:
To create a python program to implement the stack operations (list)
Algorithm:
Step-1: Start the program.
Step2: Define required stack functions
Step-3: Create an empty stack
Step-4: Display the menu for stack operations
Step-5: Read the user choice.
Step-6: Perform the stack operation based on the user’s choice.
Step-7: Display the result.
Step-8: Stop the program
EX.NO: 15
CREATING A PYTHON PROGRAM TO IMPLEMENT STACK
OPERATIONS(Dictionary)
Algorithm:
Step-1: Start the program.
Step2: Define required stack functions
Step-3: Create an empty stack
Step-4: Display the menu for stack operations
Step-5: Read the user choice.
Step6: Create an empty dictionary
Step-7: Perform the stack operation based on the user’s choice.
Step-8: Display the result.
Step-9: Stop the program
Ex.No:16
CREATING A PYTHON PROGRAM TO INTEGRATE MYSQL WITH PYTHON
(CREATING DATABASE AND TABLE)
Algorithm:
Step 1: Open the python script mode
Step 2: Import MySQL. Connector package
Step3: Define a Create_DB() function and Create_Table() function with an appropriate statements .
Step4: Establish a connection in between MySQL and python though connection object name
Step 5: Check the connection whether the python and MySQL connected or not
Step 4: If the conditions is true activate the cursor by using the cursor() function and execute the
SQL queries
Step 5: Get the input from the users
Step6: Check the choices, If the choice becomes true body of the statement has to be executed
Step7: Stop the program