0% found this document useful (0 votes)
3 views18 pages

Computer Science Practicals

The document outlines a series of programming tasks, including basic arithmetic operations, checking for perfect and Armstrong numbers, calculating factorials, generating Fibonacci series, and checking for palindromes. It also includes file manipulation tasks such as reading files, removing specific lines, counting character types, and creating binary files. Additionally, it covers SQL operations integrated with Python, including table modifications and data queries.

Uploaded by

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

Computer Science Practicals

The document outlines a series of programming tasks, including basic arithmetic operations, checking for perfect and Armstrong numbers, calculating factorials, generating Fibonacci series, and checking for palindromes. It also includes file manipulation tasks such as reading files, removing specific lines, counting character types, and creating binary files. Additionally, it covers SQL operations integrated with Python, including table modifications and data queries.

Uploaded by

clucher3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Program 1: Program to enter two numbers and print

the arithmetic operations like +,-,*, /, // and %.

Output:

Program 2: Write a program to find whether an


inputted number is perfect or not.
Output:

Program 3: Write a Program to check if the entered


number is Armstrong or not.

Output:

OR
Output:

Program 4: Write a Program to find factorial of the


entered number.

Output:

Program 5: Write a Program to enter the number of


terms and to print the Fibonacci Series.
Output:

Program 6: Write a Program to enter the string and to


check if it’s palindrome or not using loop.
Output:

OR

Output:
OR

Output:

Yes

Program 7: Recursively find the factorial of a natural


number.

Output:
Program 8: Read a file line by line and print it.

Assume we have the following file, located in the same folder


as Python:

Output:

Program 9: Remove all the lines that contain the


character “a” in a file and write it into another file.

Assume we have the following file, located in the same folder


as Python:
Output:

Program 10 Read a text file and display the number of


vowels/consonants/uppercase/lowercase characters in
the file.

Actual text file


Output:

Program 11 Create a binary file with name and roll no.


Search for a given roll number and display the name, if
not found display appropriate message.
Output:
OR
Output:
Program 12 Write a random number generator that
generates random numbers between 1 and 6(simulates
a dice)

Output:

Program 13 Write a python program to implement a


stack using a list data structure.

Stack Concept:

Output:
Queue Concept:

Output:

Program 14 Take a sample of ten phishing e-mails (or


any text file) and find most commonly occurring
word(s)

Output:
Program 15 Read a text file line by line and display
each word separated by a #

Output:

Program 16 Create a student table and insert data.


Implement the following SQL commands on the
student table:

ALTER table to add new attributes / modify data type /


drop attribute

UPDATE table to modify data

ORDER By to display data in ascending / descending


order

DELETE to remove tuple(s)

GROUP BY and find the min, max, sum, count and


average
Program 17:Integrate SQL with Python by importing
the MySQL module

Program 18:Integrate SQL with Python by importing


the pymysql module

You might also like