0% found this document useful (0 votes)
28 views13 pages

CS Class 11 Practical Ideas

Uploaded by

invictusdraco769
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)
28 views13 pages

CS Class 11 Practical Ideas

Uploaded by

invictusdraco769
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/ 13

1. DOUBLE THE ODD VALUES AND HALF THE EVEN VALUES USING 2.

2. COUNT EVEN AND ODD NUMBERS USING FUNCTION (TUPLE)


FUNCTION (LIST) AIM:
To write a program to input n numbers in tuple and pass it to function to count
AIM- To write a program to pass list to a function and double the odd values and half even how many even and odd numbers are entered.
values of a list and display list element after changing
SOFTWARE USED: IDLE (PYTHON 3.8 64-bit)
SOFTWARE USED- IDLE (PYTHON 3.8 64-bit) PROGRAM:
PROGRAM:

RESULT:
Thus, by using the Python code the following counting of the number of even numbers as
well as number of odd numbers gets checked in a tuple.
RESULT:
Thus by using Python code the element in the list get doubled and it can print on the
screen OUTPUT

OUTPUT
3. CREATE AND UPDATE DICTIONARY 4. IMPLEMENTING PYTHON LIST FUNCTIONS
AIM:
To write a python program to create dictionary with key and value and update value at AIM: To write a python program to implement list functions using user define function
that key using function. SOFTWARE USED: IDLE (PYTHON 3.8 64-BIT)
SOFTWARE USED: IDLE (PYTHON 3.8 64-BIT)
PROGRAM: PROGRAM:

RESULT:
RESULT: Thus by using python coding List inbuilt function is implemented successfully.
Thus by using python coding dictionary is created and updated successfully. OUTPUT:

OUTPUT:
5. IMPLEMENTING PYTHON MATHEMATICAL FUNCTIONS elif x==6:
AIM: angle=int(input("Enter angle in degrees: "))
To write a program to implement python mathematical functions. angle_new = (3.14 / 180)*angle
SOFTWARE USED: IDLE (PYTHON 3.8 64-BIT) print(math.cos(angle_new))
PROGRAM:
#7
elif x==7:
angle=int(input("Enter angle in degrees: "))
angle_new = (3.14 / 180)*angle
print(math.tan(angle_new))
#8
elif x==8:
print(e)
#9
elif x==9:
print(pi)
# 10
elif x==10:
print(tau)
else:
print("Please enter a valid numbers as Input")
#2
elif x==2: RESULT:
a =int(input("Enter a number" )) Thus, by using python coding python mathematical functions is implemented successfully.
for i in range(1,a+1):
x=x*i OUTPUT:
print("Factorial of the given number: ",x)
#3
elif x==3:
a =int(input("Enter a number"))
b=int(input("Enter the power"))
print(math.pow(a,b))
#4
elif x==4:
a =int(input("Enter a number”))
b=int(input("Enter a base:"))
print(math.log(a, b))
#5
elif x==5:
angle=int(input("Enter angle in degrees: "))
angle_new = (3.14 / 180)*angle
print(math.sin(angle_new))
#6
7. GENERATE RANDOM NUMBERS BETWEEN 1 AND 6 (SIMULATES A DICE)

AIM- To write a program to generator that generates random numbers between 1 and 6 using
user defined function
SOFTWARE USED- IDLE (PYTHON 3.8 64-BIT)
PROGRAM:
6. IMPLEMENTING PYTHON STRING FUNCTIONS

AIM- To write a python program to implement python string functions


SOFTWARE USED- IDLE (PYTHON 3.8 64-BIT.
PROGRAM:

RESULT:
Thus, by using python program random numbers between 1 and 6 using user defined function is
generated successfully.
OUTPUT:

RESULT:
Thus, by using python coding string functions are implemented successfully.

OUTPUT: 8. TEXT FILE LINE BY LINE AND DISPLAY EACH WORD SEPARATED BY A ‘#’
AIM- To write a program to read and display file content line by line with each
word separated by #. if c.islower():
SOFTWARE USED- IDLE (PYTHON 3.8 64-BIT) f.write(c)
PROGRAM: elif c.isupper():
f1.write(c)
else:
f2.write(c)
f.close()
f1.close()
f2.close()

RESULT:
Thus, by using python coding Text File is created and lower case, upper case and other
symbols are stored in three new different files successfully.

OUTPUT:
OUTPUT:

RESULT:
Thus, using python coding to read and display file content line by line with each word
separated by # is executed successfully.

9. TEXT FILE- STORING LOWER CASE, UPPER CASE AND OTHER SYMBOLS
IN THREE NEW DIFFERENT FILE.
AIM- To write a program to read characters from keyboard one by one, all
lower case letters gets stored inside a file “lower”, all uppercase letters gets
stored inside a file “upper”, and all other characters get stored inside “other”.

SOFTWARE USED- IDLE (PYTHON 3.8 64-bit)


PROGRAM:
f=open("lower.txt","w")
f1=open("upper.txt","w")
f2=open("other.txt","w")
print("Input '~' to stop execution")
while True:
c=input("Enter a single character:") 10. TEXT FILE - REMOVE ALL THE LINES CONTAIN THE CHARACTER
if c=='~': ‘a’ TO ANOTHER FILE.
break AIM: To write a python program to remove all the lines that contain the
elif c.isalnum(): character ‘a’ in a file and write it to another file.
alphabet ‘W’ or ‘A’.
SOFTWARE USED- IDLE (PYTHON 3.8 64-BIT) SOFTWARE USED- IDLE (PYTHON 3.8 64-BIT)
PROGRAM: PROGRAM:

RESULT: RESULT:
Thus, by using python program all the lines that contain the character ‘a’ in a
Thus, by using a python program a text file ‘Sample.txt’ is read and the
file is removed and written it to another file successfully.
number of lines which is starting with an alphabet ‘W’ or ‘A’ are count and
OUTPUT: printed successfully.

OUTPUT:

11. TEXT FILE – COUNT AND DISPLAY LINE STARTS WITH AN 12. TEXT FILE- DISPLAY TWO CHARACTER WORDS
ALPHABET ‘W’ OR ‘A’. AIM:
AIM: To write a python program to read a text file and a function in python To write a function in python to read lines from file “POEM.txt” and display
to count the number lines in a text file ‘Sample.txt’ which is starting with an all those words, which has two characters in it.
SOFTWARE USED- IDLE (PYTHON 3.8 64-BIT) PROGRAM:
PROGRAM:

RESULT:
Thus, by using python program a text file POEM.txt is read and two-character words are
printed successfully.
OUTPUT:

RESULT:
Thus, by using python program binary file is created and record is searched
successfully.

13.BINARY FILE – SEARCH AND DISPLAY OUTPUT:


AIM: To write a program to create a binary file with name and roll number. Search for a
given roll number and display the name, if not found display an appropriate message.
SOFTWARE USED- IDLE (PYTHON 3.8 64-BIT)
14. BINARY FILE – SEARCH AND UPDATE THE MARKS.
AIM: To write a program to create a binary file with roll number, name and marks. Input
a roll number and update the marks.
SOFTWARE USED- IDLE (PYTHON 3.8 64-BIT)
PROGRAM:

RESULT:
Thus, by using python program a binary file is created with roll number, name and
marks. Marks of the student is updated successfully.
15. CSV FILE BY ENTERING USER-ID AND PASSWORD, READ AND
OUTPUT: SEARCH THE PASSWORD FOR GIVEN USERID.

AIM: To write a python program to create a CSV file by entering user-id and password,
read and search the password for given userid.

SOFTWARE USED- IDLE (PYTHON 3.8 64-BIT)

PROGRAM:

RESULT:
Thus, by using python program CSV file is created with user-id and password and to the
given userid, password is searched successfully.
16. IMPLEMENT A STACK USING LIST
OUTPUT: AIM- To write a program to create Lpush() and Lpop() function to
do push and pop operation on a stack using a list.
SOFTWARE USED- IDLE (PYTHON 3.8 64-BIT)

PROGRAM:
RESULT: Thus, by using Python program a stack using list is implemented successfully.
17. INTERFACE WITH PYTHON - DISPLAY THE RECORDS
OUTPUT:
AIM- To write a program to Integrate SQL with Python by importing the
MySQL module record of employee and display the record.

SOFTWARE USED- IDLE (PYTHON 3.8 64-BIT), MySQL Workbench 8.0 CE

PROGRAM:

RESULT:
Thus, by using interface python program employee records are displayed successfully.

OUTPUT:
18. INTERFACE WITH PYTHON - DISPLAY THE RECORDS
19. INTERFACE WITH PYTHON - SEARCH AND UPDATE THE RECORD
AIM: To write a program to Integrate SQL with Python by importing the AIM: To write a program to Integrate SQL with Python by importing the
MySQL module to search an employee using empno and if present in table print the MySQL module to search and update the record.
record, if not print appropriate message. SOFTWARE USED- IDLE (PYTHON 3.8 64-BIT), MySQL Workbench 8.0 CE
PROGRAM:
SOFTWARE USED- IDLE (PYTHON 3.8 64-BIT), MySQL Workbench 8.0 CE

PROGRAM:

RESULT: RESULT:
Thus, by using interface python program employee record is searched and displayed Thus, by using interface python program employee record is searched and displayed
successfully. successfully.
OUTPUT:

OUTPUT:
OUTPUT:

20. INTERFACE WITH PYTHON- SEARCH AND DELETE THE RECORD


AIM: To write a program to Integrate SQL with Python by importing the
MySQL module to search and delete the record.
SOFTWARE USED- IDLE (PYTHON 3.8 64-BIT), MySQL Workbench 8.0 CE
PROGRAM:

RESULT:
Thus, by using interface python program employee record is searched, deleted and displayed
successfully.

You might also like