The document contains 20 Python programs with summaries and outputs. The programs cover topics like palindrome strings, removing odd numbers from lists, finding sums of list elements ending in 3, creating tuples from user input, stack operations, MySQL connectivity, binary file handling and more.
COMPUTER SCIENCE CLASS 12 PRACTICAL FILEAnushka Rai
Here's my Computer Science Board Practical File. I hope you find it as useful as it was to me.This file is however of CBSE class 12th 2020-2021 syllabus.
CBSE Class 12 Computer practical Python Programs and MYSQL Rishabh-Rawat
This upload is my Computer Science Practical File for CBSE class 12 Board exam practical.
Some errors in the displaying of the content might have crept in as I prepared this file on my android. ;P
COMPUTER SCIENCE CLASS 12 PRACTICAL FILEAnushka Rai
Here's my Computer Science Board Practical File. I hope you find it as useful as it was to me.This file is however of CBSE class 12th 2020-2021 syllabus.
CBSE Class 12 Computer practical Python Programs and MYSQL Rishabh-Rawat
This upload is my Computer Science Practical File for CBSE class 12 Board exam practical.
Some errors in the displaying of the content might have crept in as I prepared this file on my android. ;P
Create a C program which auto-completes suggestions when beginning t.pdffedosys
Create a C program which auto-completes suggestions when beginning to type a command and
pressing tab. The program needs to read all the files names in a directory given by the user and
store them in a data structure made up of a 26-element array of linked lists. A linked list
implementation in C is required. Create a linked list for each letter of the alphabet in which
you\'ll store the filenames which begin with that letter in some order. After reading the
filenames, the user provides the beginning of a filename they\'ll like to search. The output should
be all the filenames which match that prefix. The program should continue to ask for beginnings
of filenames until an empty string is entered.
Solution
Code
-----------
#include
#include
#include
struct node
{
char data[10] ;
struct node *next;
}*head;
node* arrNode[26];
char lettersPosition[26] =
{\'a\',\'b\',\'c\',\'d\',\'e\',\'f\',\'g\',\'h\',\'i\',\'j\',\'k\',\'l\',\'m\',\'n\',\'o\',\'p\',\'q\',\'r\',\'s\',\'t\',\'u\',\'v\',\'w\',\'x
\',\'y\',\'z\'};
/*
* Creating Node
*/
node* create_node(char fileName[])
{
node* newnode = (node *)malloc(sizeof(node));
if (newnode == NULL)
{
printf(\"\ Memory was not allocated\");
return 0;
}
else
{
strcpy(newnode->data,fileName);
newnode->next = NULL;
return newnode;
}
}
void display(struct node *r)
{
r=head;
if(r==NULL)
{
return;
}
while(r!=NULL)
{
printf(\"%s \",r->data);
r=r->next;
}
printf(\"\ \");
}
void search(char beginningFilePrefix[])
{
node* newnode = NULL;
char str[10];
strcpy(str,beginningFilePrefix);
char dirPos = str[0];
node* r = arrNode[lettersPosition[dirPos]];
if(r==NULL){
printf( \"No file is avialable in directory\");
return;
}else{
while(r!=NULL){
char tempFile[10];
bool isMathched = true;
strcpy(tempFile,r->data);
for( int i = 0; i < 1 ; i++){
printf(\"%c %c\",str[i],tempFile[i]);
if(!(str[i] == tempFile[i])){
isMathched = false;
}
}
if(isMathched){
if(newnode == NULL){
newnode = (node *)malloc(sizeof(node));
strcpy(newnode->data,r->data);
}else{
struct node *temp,*right;
temp= (struct node *)malloc(sizeof(struct node));
strcpy(temp->data,r->data);
right=(struct node *)newnode;
while(right->next != NULL){
right=right->next;
}
right->next =temp;
right=temp;
right->next=NULL;
}
}
r=r->next;
}
}
if(newnode==NULL){
printf(\"File not found with given search critieria\");
}else{
printf(\" Below are the output or file list which are matched with search criteria \ \");
while(newnode!=NULL){
printf(\"%s \ \",newnode->data);
newnode=newnode->next;
}
}
printf(\"\ \");
}
void displayFromArray(int dirPosition)
{
node* r= arrNode[dirPosition];
if(r==NULL){
printf( \"r is null\");
return;
}
while(r!=NULL){
printf(\"%s \",r->data);
r=r->next;
}
printf(\"\ \");
}
void insertIntoArray(char fileName[],int dirPosition){
struct node *temp;
temp=(struct node *)malloc(sizeof(struct node));
strcpy(temp->data,fileName);
node* r = arrNode[dirPosition];
if(lettersPosition[dirPosition] == fileName[0]){
printf(\"directory starts with letter %c cannot hold fi.
Hierarchical Digital Twin of a Naval Power SystemKerry Sado
A hierarchical digital twin of a Naval DC power system has been developed and experimentally verified. Similar to other state-of-the-art digital twins, this technology creates a digital replica of the physical system executed in real-time or faster, which can modify hardware controls. However, its advantage stems from distributing computational efforts by utilizing a hierarchical structure composed of lower-level digital twin blocks and a higher-level system digital twin. Each digital twin block is associated with a physical subsystem of the hardware and communicates with a singular system digital twin, which creates a system-level response. By extracting information from each level of the hierarchy, power system controls of the hardware were reconfigured autonomously. This hierarchical digital twin development offers several advantages over other digital twins, particularly in the field of naval power systems. The hierarchical structure allows for greater computational efficiency and scalability while the ability to autonomously reconfigure hardware controls offers increased flexibility and responsiveness. The hierarchical decomposition and models utilized were well aligned with the physical twin, as indicated by the maximum deviations between the developed digital twin hierarchy and the hardware.
Create a C program which auto-completes suggestions when beginning t.pdffedosys
Create a C program which auto-completes suggestions when beginning to type a command and
pressing tab. The program needs to read all the files names in a directory given by the user and
store them in a data structure made up of a 26-element array of linked lists. A linked list
implementation in C is required. Create a linked list for each letter of the alphabet in which
you\'ll store the filenames which begin with that letter in some order. After reading the
filenames, the user provides the beginning of a filename they\'ll like to search. The output should
be all the filenames which match that prefix. The program should continue to ask for beginnings
of filenames until an empty string is entered.
Solution
Code
-----------
#include
#include
#include
struct node
{
char data[10] ;
struct node *next;
}*head;
node* arrNode[26];
char lettersPosition[26] =
{\'a\',\'b\',\'c\',\'d\',\'e\',\'f\',\'g\',\'h\',\'i\',\'j\',\'k\',\'l\',\'m\',\'n\',\'o\',\'p\',\'q\',\'r\',\'s\',\'t\',\'u\',\'v\',\'w\',\'x
\',\'y\',\'z\'};
/*
* Creating Node
*/
node* create_node(char fileName[])
{
node* newnode = (node *)malloc(sizeof(node));
if (newnode == NULL)
{
printf(\"\ Memory was not allocated\");
return 0;
}
else
{
strcpy(newnode->data,fileName);
newnode->next = NULL;
return newnode;
}
}
void display(struct node *r)
{
r=head;
if(r==NULL)
{
return;
}
while(r!=NULL)
{
printf(\"%s \",r->data);
r=r->next;
}
printf(\"\ \");
}
void search(char beginningFilePrefix[])
{
node* newnode = NULL;
char str[10];
strcpy(str,beginningFilePrefix);
char dirPos = str[0];
node* r = arrNode[lettersPosition[dirPos]];
if(r==NULL){
printf( \"No file is avialable in directory\");
return;
}else{
while(r!=NULL){
char tempFile[10];
bool isMathched = true;
strcpy(tempFile,r->data);
for( int i = 0; i < 1 ; i++){
printf(\"%c %c\",str[i],tempFile[i]);
if(!(str[i] == tempFile[i])){
isMathched = false;
}
}
if(isMathched){
if(newnode == NULL){
newnode = (node *)malloc(sizeof(node));
strcpy(newnode->data,r->data);
}else{
struct node *temp,*right;
temp= (struct node *)malloc(sizeof(struct node));
strcpy(temp->data,r->data);
right=(struct node *)newnode;
while(right->next != NULL){
right=right->next;
}
right->next =temp;
right=temp;
right->next=NULL;
}
}
r=r->next;
}
}
if(newnode==NULL){
printf(\"File not found with given search critieria\");
}else{
printf(\" Below are the output or file list which are matched with search criteria \ \");
while(newnode!=NULL){
printf(\"%s \ \",newnode->data);
newnode=newnode->next;
}
}
printf(\"\ \");
}
void displayFromArray(int dirPosition)
{
node* r= arrNode[dirPosition];
if(r==NULL){
printf( \"r is null\");
return;
}
while(r!=NULL){
printf(\"%s \",r->data);
r=r->next;
}
printf(\"\ \");
}
void insertIntoArray(char fileName[],int dirPosition){
struct node *temp;
temp=(struct node *)malloc(sizeof(struct node));
strcpy(temp->data,fileName);
node* r = arrNode[dirPosition];
if(lettersPosition[dirPosition] == fileName[0]){
printf(\"directory starts with letter %c cannot hold fi.
Hierarchical Digital Twin of a Naval Power SystemKerry Sado
A hierarchical digital twin of a Naval DC power system has been developed and experimentally verified. Similar to other state-of-the-art digital twins, this technology creates a digital replica of the physical system executed in real-time or faster, which can modify hardware controls. However, its advantage stems from distributing computational efforts by utilizing a hierarchical structure composed of lower-level digital twin blocks and a higher-level system digital twin. Each digital twin block is associated with a physical subsystem of the hardware and communicates with a singular system digital twin, which creates a system-level response. By extracting information from each level of the hierarchy, power system controls of the hardware were reconfigured autonomously. This hierarchical digital twin development offers several advantages over other digital twins, particularly in the field of naval power systems. The hierarchical structure allows for greater computational efficiency and scalability while the ability to autonomously reconfigure hardware controls offers increased flexibility and responsiveness. The hierarchical decomposition and models utilized were well aligned with the physical twin, as indicated by the maximum deviations between the developed digital twin hierarchy and the hardware.
HEAP SORT ILLUSTRATED WITH HEAPIFY, BUILD HEAP FOR DYNAMIC ARRAYS.
Heap sort is a comparison-based sorting technique based on Binary Heap data structure. It is similar to the selection sort where we first find the minimum element and place the minimum element at the beginning. Repeat the same process for the remaining elements.
Saudi Arabia stands as a titan in the global energy landscape, renowned for its abundant oil and gas resources. It's the largest exporter of petroleum and holds some of the world's most significant reserves. Let's delve into the top 10 oil and gas projects shaping Saudi Arabia's energy future in 2024.
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdffxintegritypublishin
Advancements in technology unveil a myriad of electrical and electronic breakthroughs geared towards efficiently harnessing limited resources to meet human energy demands. The optimization of hybrid solar PV panels and pumped hydro energy supply systems plays a pivotal role in utilizing natural resources effectively. This initiative not only benefits humanity but also fosters environmental sustainability. The study investigated the design optimization of these hybrid systems, focusing on understanding solar radiation patterns, identifying geographical influences on solar radiation, formulating a mathematical model for system optimization, and determining the optimal configuration of PV panels and pumped hydro storage. Through a comparative analysis approach and eight weeks of data collection, the study addressed key research questions related to solar radiation patterns and optimal system design. The findings highlighted regions with heightened solar radiation levels, showcasing substantial potential for power generation and emphasizing the system's efficiency. Optimizing system design significantly boosted power generation, promoted renewable energy utilization, and enhanced energy storage capacity. The study underscored the benefits of optimizing hybrid solar PV panels and pumped hydro energy supply systems for sustainable energy usage. Optimizing the design of solar PV panels and pumped hydro energy supply systems as examined across diverse climatic conditions in a developing country, not only enhances power generation but also improves the integration of renewable energy sources and boosts energy storage capacities, particularly beneficial for less economically prosperous regions. Additionally, the study provides valuable insights for advancing energy research in economically viable areas. Recommendations included conducting site-specific assessments, utilizing advanced modeling tools, implementing regular maintenance protocols, and enhancing communication among system components.
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)MdTanvirMahtab2
This presentation is about the working procedure of Shahjalal Fertilizer Company Limited (SFCL). A Govt. owned Company of Bangladesh Chemical Industries Corporation under Ministry of Industries.
Using recycled concrete aggregates (RCA) for pavements is crucial to achieving sustainability. Implementing RCA for new pavement can minimize carbon footprint, conserve natural resources, reduce harmful emissions, and lower life cycle costs. Compared to natural aggregate (NA), RCA pavement has fewer comprehensive studies and sustainability assessments.
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERSveerababupersonal22
It consists of cw radar and fmcw radar ,range measurement,if amplifier and fmcw altimeterThe CW radar operates using continuous wave transmission, while the FMCW radar employs frequency-modulated continuous wave technology. Range measurement is a crucial aspect of radar systems, providing information about the distance to a target. The IF amplifier plays a key role in signal processing, amplifying intermediate frequency signals for further analysis. The FMCW altimeter utilizes frequency-modulated continuous wave technology to accurately measure altitude above a reference point.
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Dr.Costas Sachpazis
Terzaghi's soil bearing capacity theory, developed by Karl Terzaghi, is a fundamental principle in geotechnical engineering used to determine the bearing capacity of shallow foundations. This theory provides a method to calculate the ultimate bearing capacity of soil, which is the maximum load per unit area that the soil can support without undergoing shear failure. The Calculation HTML Code included.
Water billing management system project report.pdfKamal Acharya
Our project entitled “Water Billing Management System” aims is to generate Water bill with all the charges and penalty. Manual system that is employed is extremely laborious and quite inadequate. It only makes the process more difficult and hard.
The aim of our project is to develop a system that is meant to partially computerize the work performed in the Water Board like generating monthly Water bill, record of consuming unit of water, store record of the customer and previous unpaid record.
We used HTML/PHP as front end and MYSQL as back end for developing our project. HTML is primarily a visual design environment. We can create a android application by designing the form and that make up the user interface. Adding android application code to the form and the objects such as buttons and text boxes on them and adding any required support code in additional modular.
MySQL is free open source database that facilitates the effective management of the databases by connecting them to the software. It is a stable ,reliable and the powerful solution with the advanced features and advantages which are as follows: Data Security.MySQL is free open source database that facilitates the effective management of the databases by connecting them to the software.
We have compiled the most important slides from each speaker's presentation. This year’s compilation, available for free, captures the key insights and contributions shared during the DfMAy 2024 conference.
2. INDEX
PROGRAM 1 : Write a program to show entered string is a palindrome or not.
PROGRAM 2 : WAP to remove all odd numbers from the given list.
PROGRAM 3 : Write a program to find and display the sum of all the values which are ending with 3 from a list
PROGRAM 4 : Write a program to accept values from a user and create a tuple
PROGRAM 5 : Write a program to find and display the sum of all the values which are ending with 3 from a list
PROGRAM 6 : Write a program to show all non -prime numbers in the entered range .
PROGRAM 7 : Write a program to find factorial of entered number using library function fact().
PROGRAM 8 : Program20 : Write a program to show and count the number of words in a text file ‘DATA.TXT’
which is starting/ended with an word ‘The’, ‘the’, ‘my’, ‘he’, ‘they’
PROGRAM 9 : Write a program to read data from a text file DATA.TXT, and display each words with number of
vowels and consonants.
3. INDEX
PROGRAM 10 : Write a program to insert list data in CSV File and print it.
PROGRAM 11 : Write a program that rotates the elements of a list so that the element at the first index moves
to the second index, the element in the second index moves to the third
index, etc., and the element in the last index moves to the first index.
PROGRAM 12 : Write a program to show push and pop operation using stack
PROGRAM 13 : Write a program to show MySQL CONNECTIVITY for inserting two tuples in
table:"student" inside database:"class12" .
PROGRAM 14 : Write a program to call great func() to find greater out of entered two numbers, using
import command .
PROGRAM 15 : Write a program that will write a string binary file "school.dat" and display the words of
the string in reverse order.
PROGRAM 16 :Write a program to insert item on selected position in list and print the updated list.
4. PROGRAM 1:WAP TO ACCEPT A STRING AND WHETHER IT IS A
PALINDROME OR NOT.
str=input("enter the string")
l=len(str)
p=l-1
index=0
while(index<p):
if(str[index]==str[p]):
index=index+1
p=p-1
else:
print("string is not a palindrome") OUTPUT:
break enter a string : NITIN
else: string is palindromee
print("string is palindrome")
5. PROGRAM 2:WAP TO REMOVE ALL ODD NUMBERS FROM THE
GIVEN LIST.
L=[2,7,12,5,10,15,23]
for i in L:
if i%2==0:
L.remove(i) OUTPUT:
print(L) [7,5,15,23]
6. PROGRAM 3:WAP TO FIND AND DISPLAY THE SUM OF ALL THE
VALUES WHICH ARE ENDING WITH 3 FROM A LIST
L=[33,13,92,99,3,12]
sum=0
x=len(L)
for i in range(0,x): OUTPUT:
if type(L[i])==int: 49
if L[i]%10==3:
sum+=L[i]
print(sum)
7. PROGRAM4: WRITE A PROGRAM TO ACCEPT VALUES FROM A
USER AND CREATE A TUPLE.
t=tuple()
n=int(input("enter limit:"))
for i in range(n):
a=input("enter number:")
t=t+(a,)
print("output is")
print(t)
8. PROGRAM 5:WAP TO FIND AND DISPLAY THE SUM OF ALL THE
VALUES WHICH ARE ENDING WITH 3 FROM A LIST.
L=[33,13,92,99,3,12]
sum=0
x=len(L)
for i in range(0,x): OUTPUT:6
if type(L[i])==int:
if L[i]%10==3:
sum+=L[i]
print(sum)
9. PROGRAM 6: WRITE A PROGRAM TO SHOW ALL NON -PRIME
NUMBERS IN THE ENTERED RANGE
def nprime(lower,upper):
print("“SHOW ALL NUMBERS EXCEPT PRIME NUMBERS WITHIN THE RANGE”")
for i in range(lower, upper+1): OUTPUT:
for j in range(2, i): Enter lowest number as lower bound to check : 3
Enter highest number as upper bound to check : 41
ans = i % j SHOW ALL NUMBERS EXCEPT PRIME
NUMBERS WITHIN THE RANGE
if ans==0: 4,6,8,10,12,14,18,20,22,24,26,28,30,32,34,36,38,40
NONE
print (i,end=' ')
break
lower=int(input("Enter lowest number as lower bound to check : "))
upper=int(input("Enter highest number as upper bound to check: "))
reply=nprime(lower,upper)
print(reply)
10. PROGRAM 7 : WRITE A PROGRAM TO FIND FACTORIAL OF
ENTERED NUMBER USING LIBRARY FUNCTION FACT().
def fact(n):
if n<2:
return 1 OUTPUT:
else : ENTER VALUE FOR FACTORIAL: 12
the factorial of the number is :479001600
return n*fact(n-1)
import factfunc
x=int(input("Enter value for factorial : "))
ans=factfunc.fact(x)
print (ans)
11. PROGRAM 8 : WRITE A PROGRAM TO SHOW AND COUNT THE
NUMBER OF WORDS IN A TEXT FILE ‘DATA.TXT’ WHICH IS
STARTING/ENDED WITH AN WORD ‘THE’, ‘THE’, ‘MY’, ‘HE’, ‘THEY’
f1=open("data.txt","r")
s=f1.read()
print("All Data of file in string : n",s)
print("="*30)
count=0
words=s.split()
print("All Words: ",words,", length is ",len(words))
for word in words:
if word.startswith("the")==True: # word.ends with(“the”)
count+=1
print("Words start with 'the' is ",count)
12. PROGRAM 9 : WRITE A PROGRAM TO READ DATA FROM A TEXT
FILE DATA.TXT, AND DISPLAY EACH WORDS WITH NUMBER OF
VOWELS AND CONSONANTS.
f1=open("data.txt","r")
s=f1.read()
print(s)
countV=0
countC=0
words=s.split()
print(words,", ",len(words))
for word in words:
countV=0
countC=0
for ch in word:
if ch.isalnum()==True:
if ch=='a' or ch=='e' or ch=='i' or ch=='o' or ch=='u':
countV+=1
else:
countC+=1
print("Word : ",word,", V: ",countV,", C= ", countC)
13. PROGRAM 10 : WRITE A PROGRAM TO INSERT LIST DATA IN CSV
FILE AND PRINT IT.
import csv
fields = ['Name', 'Branch', 'Year', 'CGPA'] # field names
# data rows of csv file
rows = [ ['Nikhil', 'COE', '2', '9.0'],
['Sanchit', 'COE', '2', '9.1'],
['Aditya', 'IT', '2', '9.3'],
['Sagar', 'SE', '1', '9.5'],
['Prateek', 'MCE', '3', '7.8'],
['Sahil', 'EP', '2', '9.1']]
filename = "MYCSV.csv"
with open(filename, 'w') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerow(fields)
csvwriter.writerows(rows)
with open('MYCSV.csv', newline='') as File:
reader = csv.reader(File)
for row in reader:
print(row)
14. PROGRAM 11 : WRITE A PROGRAM THAT ROTATES THE ELEMENTS OF A LIST
SO THAT THE ELEMENT AT THE FIRST INDEX MOVES TO THE SECOND INDEX,
THE ELEMENT IN THE SECOND INDEX MOVES TO THE THIRD
INDEX, ETC., AND THE ELEMENT IN THE LAST INDEX MOVES TO THE FIRST
INDEX.
n=int(input("Enter Number of items in List: "))
DATA=[]
for i in range(n):
item=int(input("Item :%d: "%(i+1)))
DATA.append(item)
print("Now List Items are :",DATA)
lg=len(DATA)
print("Now Number of items before update are :",lg)
b=["undef"]*lg
for x in (range(lg-1)):
if (x)>lg:
break
b[x+1]=DATA[x]
b[0]=DATA[-1]
print("RESULT OF NEW LIST IS " , b)
15. PROGRAM 13 : WRITE A PROGRAM TO SHOW PUSH AND
POP OPERATION USING STACK
def push(stack,x): #function to add element at the end of list
stack.append(x)
def pop(stack): #function to remove last element from list
n = len(stack)
if(n<=0):
print("Stack empty....Pop not possible")
else:
stack.pop()
def display(stack): #function to display stack entry
if len(stack)<=0:
print("Stack empty...........Nothing to display")
for i in stack:
print(i,end=" ")
#main program starts from here
x=[]
choice=0
while (choice!=4):
print("********Stack Menu***********")
print("1. push(INSERT)")
print("2. pop(DELETE)")
print("3. Display ")
print("4. Exit")
choice = int(input("Enter your choice :"))
if(choice==1):
value = int(input("Enter value "))
push(x,value)
if(choice==2):
pop(x)
if(choice==3):
display(x)
if(choice==4):
16. PROGRAM 15: WRITE A PROGRAM TO SHOW MYSQL
CONNECTIVITY FOR INSERTING TWO TUPLES IN
TABLE:"STUDENT" INSIDE DATABASE:"CLASS12" .
import mysql.connector as m
db=m.connect(host="localhost",user="root",passwd="h",database="class12")
cursor_obj=db.cursor()
cursor_obj.execute("INSERT INTO
student(admno,name,class,sec,rno,address)VALUES({},'{}','{}','{}',{},'{}')".format(1236,"kamala",11,'a',43,"
NARELA"))
cursor_obj.execute("INSERT
INTOstudent(admno,name,class,sec,rno,address)VALUES({},'{}','{}','{}',{},'{}')".format(1237,"kishore",12,'
c',3,"NARELA"))
db.commit()
print("record inserted")
cursor_obj.execute("select * from student")
data=cursor_obj.fetchall()
for row in data:
print(row)
17. PROGRAM 18 : WRITE A PROGRAM TO CALL GREAT FUNC() TO
FIND GREATER OUT OF ENTERED TWO NUMBERS, USING IMPORT
COMMAND .
def chknos(a, b):
if a>b:
print("the first number ",a,"is greater") OUTPUT:
return a ENTER FIREST NUMBER : 74
else: ENTER SECOND NUMBER: 34
print("the second number ",b,"is greater") THE FIREST NUMBER 74 is greater
return b greatest number = 67
import greatfunc
a=int(input("Enter First Number : "))
b=int(input("Enter Second Number : "))
ans=greatfunc.chknos(a, b)
print("GREATEST NUMBER = ",ans)
18. PROGRAM 19 : WRITE A PROGRAM THAT WILL WRITE A STRING
BINARY FILE "SCHOOL.DAT" AND DISPLAY THE WORDS OF THE
STRING IN REVERSE ORDER.
f1=open('school.dat','rb')
str1=pickle.load(f1)
print("nnthe string in the binary file is : n",str1)
str1=str.split(" ")
l=list(str1)
print("nthe list is ",l)
length=len(l)
while length>0:
print(l[length-1],end=" ")
length-=1
19. PROGRAM 20 :WRITE A PROGRAM TO INSERT ITEM ON SELECTED
POSITION IN LIST AND PRINT THE UPDATED LIST.
n=int(input("Enter Number of items in List: "))
DATA=[]
for i in range(n):
item=int(input("Item :%d: "%(i+1)))
DATA.append(item)
print("Now List Items are :",DATA)
print("Now Number of items before update are :",len(DATA)) OUTPUT:
e=int(input("Enter Item = ")) enter the number of items in list: 4
pos=int(input("Enter POS = ")) item: 1 :2
DATA.append(None) item: 1 :4
item: 1 :6
item: 1 :8
le=len(DATA) new list items are :[2,4,6,8]
for i in range(le-1,pos-1,-1): no of items before updating are : 4
DATA[i]=DATA[i-1] enter item : 3
print("Now List Items are :",DATA) enter POS = 2
DATA[pos-1]=e now list of items are :5
print("Now Number of items are :",len(DATA)) now updated list items are : [2,3,4,6,8]
print("Now Updated List Items are :",DATA)