Assingment Cs Printable
Assingment Cs Printable
11 Program to enter two numbers and print the arithmetic operations like +,-
,*, /, // and %.
12 Write a program to find whether an inputted number is perfect or not. S
13 Write a Program to check if the entered number is Armstrong or not.
14 Write a Program to find factorial of the entered number
15 Write a Program to enter the number of terms and to print the Fibonacci
Series.
16 Write a Program to enter the string and to check if it’s palindrome or not
using loop.
17 Read a file line by line and print it.
18 Remove all the lines that contain the character “a” in a file and write it
into another file.
19 Read a text file and display the number of
vowels/consonants/uppercase/lowercase characters in the file.
20 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.
21 Write a random number generator that generates random numbers
between 1 and 6(simulates a dice)
22 Write a python program to implement a stack using a list data structure.
23 Take a sample of ten phishing emails (or any text file) and find most
commonly occurring word(s)
24 Read a text file line by line and display each word separated by a #
25 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 averag
26 Integrate SQL with Python by importing the MySQL module
Output:
Output:
Program03:Write a python program to input three
numbers and display the largest / smallest number.
#Checking Largest
#Checking Smallest
print(j,end=" ")
print()
v = c = uc = lc = 0
v_list =[‘a’,e,’I’,’o’,’u’]
for i in txt:
if i in v_list:
v += 1
if i not in v_list:
c += 1
if i.isupper():
uc += 1
if i.islower():
lc += 1
Output:
Program06: Write a menu driven program for list
manipulation .Display menu as:
1. Add a record
2. View record
3. Delete Record
4.Modify record 5. Exit
l=[] while True:
print('''1. Add a record
2. View record
3. Delete Record
4. Modify record 5. Exit''')
ch=int(input("Enter your choice:"))
if ch==1:
v=int(input("Enter value to add a record:"))
l.append(v)
print("Record Added...")
print("List after insertion:",l)
elif ch==2:
print(l)
elif ch==3:
n=int(input("Enter the value to
delete:"))
l.remove(n)
print("RecordDeleted...")
print("List after deletion:",l)
elif ch==4:
i=int(input("Enter position to modify the
value:"))
nv=int(input("Enter new value to modify:"))
print("Record Modified...")
print("List after modification”)
elif ch==5:
print(“Thank you! Good Bye”)
break
Output: Main Menu
Add record:
View Record:
Delete Record
Modify Record
Exit
Program07: Write a menu drive program to the
following from the list:
1. Maximum
2. Minimum
3. Sum
4. Sort in Ascending
5. Sort in Descending
6. Exit
l=[11,32,5,43,22,98,67,44]
while True:
print(''' 1. Maximum
2. Minimum
3. Sum
4. Sorting (Ascending)
5. Sorting (Descending) 6. Exit ''')
ch=int(input("Enter your choice:"))
if ch==1:
print("Maximum:",max(l))
elif ch==2:
print("Minimum:",min(l))
elif ch==3:
print("Sum:",sum(l))
elif ch==4:
l.sort()
print("Sorted list(Ascending):",l)
elif ch==5:
l.sort(reverse=True)
print("Sorted List(Descending:)",l)
elif ch==6:
print("Thank you! Good Bye")
break
Output:
Main menu
Maximum
Minimum
Sum
Sort (Ascending):
Sort(Descending):
Exit
Program08: Write a program to input a list of numbers
and swap elements at the even location with the
elements at the odd location.
i in range(0,s,2):
Output:
Program9: Write a program to Create a dictionary with
the roll number, name and marks of n students in a class
and display the names of students who have scored
marks above 75.
d={1:['Rudra',99],2:['Rushi',98],
3:['Prakash',65],4:['Jay',84]} for
i in d: if d[i][1]>75:
Output:
Program10: Write a program to create a dictionary and
store salesman name as a key and sales of 3 months as
values. Give the bonus to the salesman according to the
given criteria:
1. Total Sales < 1K – No
Bonus
2. Total Sales 1K to 2K –
5%
3. Total Sales 2.1K to 3K
– 8%
4. Total Sales 3.1K to 4K
– 10% 5. Total Sales
>4K – 12%
d={'Rudra':[199,180,540],'Rushi':[543,876,453],
'Preet':[650,987,123],'Jay':[284,456,321]}
bonus=0 for i in d:
d[i]=sum(d[i])
for i in d:
if d[i]<1000:
d[i]=0
elif d[i]>=1000 and d[i]<=2000:
d[i]=d[i]*0.05
elif d[i]>=2001 and d[i]<=3000:
d[i]=d[i]*0.08
elif d[i]>=3001 and d[i]<=4000:
d[i]=d[i]*0.1
elif d[i]>=4001:
d[i]=d[i]*0.12
OUTPUT:
Program 12: Write a program to find whether an
inputted number is perfect or not.
OUTPUT:
Program 13: Write a Program to check if the entered
number is Armstrong or not.
Output:
Program 14: Write a Program to find factorial of the
entered number.
Output:
Program 15: Write a Program to enter the number
of terms and to print the Fibonacci
Series.
Output:
Program 16: Write a Program to enter the string and to
check if it’s palindrome or not using loop.
Output:
OR
Output: Yes
Program 17: Read a file line by line and print it.
Output:
Program 18: Remove all the lines that contain the
character “a” in a file and write it into another file.
Output:
Program 19: Read a text file and display the
number of
vowels/consonants/uppercase/lowercase
characters in the file.
Output:
Program 21: Write a random number generator
that generates random numbers between 1 and
6(simulates a dice)
Output:
Output:
Program 23: Take a sample of ten phishing emails (or
any text file) and find most commonly occurring word(s)
Output:
Program 24: Read a text file line by line and display each
word separated by a #
Output:
Program 25: Create a student table and insert data.
Implement the following SQL commands on the
student table:
• GROUP BY and find the min, max, sum, count and average
SOURCE CODE:
Program 26: Integrate SQL with Python by
importing the MySQL module
Program 27: Integrate SQL with Python by
importing the py mysql module.
Program 28:Creating a Table
To create a table in MySQL, use the "CREATE TABLE"
statement.
Make sure you define the name of the database when you
create the connection.
SOURCE CODE
Program29: Database table of empl