CS - Prefinal Lab
CS - Prefinal Lab
PART-A-PYTHON PROGRAMS
1. PROGRAM -1: Write the program to find the given string is
palindrome or not.
AIM:
To write the program to find the given string is palindrome or
not.
PROGRAM:
OUTPUT1:
Palindrome checking program
Enter the string : madam
The given string madam is a palindrome
Do you want to add check for another string(y/n):y
Enter the string : eleven
The given string eleven is a palindrome
Do you want to add check for another string(y/n):n
>>>
RESULT:
Thus the above program has been executed successfully and the
output is verified.
3
AIM:
To write a random number generator that generates random
numbers between 1 and 6 (simulates a dice).
PROGRAM:
import random
print("Dice game ")
print("Game starts...")
ans='y'
while ans=='y':
print("Dice rolling ... ")
s=random.randint(1,6)
print("You got:",s)
ans=input("Do you want to roll again the dice (y/n):")
print("See you again.. Bye .. ")
OUTPUT:
Dice game
Game starts...
Dice rolling....
You got: 5
Do you want to roll again the dice (y/n):y
Dice rolling....
You got: 2
Do you want to roll again the dice (y/n):y
Dice rolling....
You got: 2
Do you want to roll again the dice (y/n):y
Dice rolling....
You got: 6
Do you want to roll again the dice (y/n):n
See you again.. Bye…
RESULT:
Thus the above program has been executed successfully and the
output is verified
4
AIM:
To read a text file and display the number of
vowels/consonants/uppercase/lowercase characters in the file.
PROGRAM:
a=open('sample.txt','r')
b=a.read()
v=c=uc=lc=0
for i in b:
if i.isalpha():
if i in ‘AEIOUaeiou’:
v+=1
else:
c+=1
if i.isupper():
uc+=1
elif i.islower():
lc+=1
print("The number of vowels in the file is :",v)
print("The number of consonants in the file is :",c)
print("The number of upper case letters in the file is :",uc)
print("The number of lower case letters in the file is :",lc)
a.close()
FILE CONTENT :
OUTPUT:
The number of vowels in the file is : 20
The number of consonants in the file is : 46
The number of upper case letters in the file is : 2
The number of lower case letters in the file is : 52
RESULT:
Thus the above program has been executed successfully and the
output is verified.
5
AIM:
To read a text file and count the number of occurrence of the
particular word in the file content.
PROGRAM:
a=open("sample.txt",'r')
b=a.read()
c=b.split()
d=0
w=input("Enter the word which you want to count:")
for i in c:
if i.lower()==w:
d+=1
if d==0:
print("The given word",w,"not found in the file content")
else:
print("The given word",w,"found",d,"time(s) in the file
content")
OUTPUT:
RESULT:
Thus the above program has been executed successfully and the
output is verified
SQL COMMANDS EXERCISE - 1
Ex.No: 20
DATE:
AIM:
To write Queries for the following Questions based on the given table:
USE STUDENTS;
SHOW DATABASES;
(e) Write a Query to List all the tables that exists in the current database.
SHOW TABLES;
Output:
SQL COMMANDS EXERCISE - 2
Ex.No: 21
DATE:
AIM:
To write Queries for the following Questions based on the given table:
(a) Write a Query to insert all the rows of above table into Info table.
(b) Write a Query to display all the details of the Employees from the above table 'STU'.
Output:
(c) Write a query to Rollno, Name and Department of the students from STU table.
Output:
Output:
********************************************************************************************
Ex.No: 22 SQL COMMANDS EXERCISE - 3
DATE:
AIM:
To write Queries for the following Questions based on the given table:
Output:
(b) Write a Query to list name of the students whose ages are between 18 to 20.
Output:
(c) Write a Query to display the name of the students whose name is starting with 'A'.
Output:
(d) Write a query to list the names of those students whose name have second alphabet 'n' in their
names.
Output:
**********************************************************************************************************
Ex.No: 23 SQL COMMANDS EXERCISE - 4
DATE:
AIM:
To write Queries for the following Questions based on the given table:
(b) Write a Query to change the fess of Student to 170 whose Roll number is 1, if the existing fess
is less than 130.
Output(After Update):
(c) Write a Query to add a new column Area of type varchar in table STU.
Output:
(d) Write a Query to Display Name of all students whose Area Contains NULL.
Output:
(e) Write a Query to delete Area Column from the table STU.
Output:
Output:
*******************************************************************************************