Program No.3: Program to Demonstrate use of list. print("PROGRAM FOR BUILT-IN METHODS OF LIST\n") animal=['Cat','Dog','Rabbit'] print("Old list:->",animal) animal.append('Cow') print("Updated list:->",animal) language=['Python','Java','C++','C'] print("Old list:->",language) return_value=language.pop(3) print("Updated List:->",language) vowels=['e','a','u','o','i'] print("Old list:->",vowels) vowels.sort() print("sorted List in Assending order:->",vowels) vowels.sort(reverse=True) print("sorted List in Desending order:->",vowels) vowel=['a','e','i','u'] print("Old list:->",vowel) vowel.insert(3,'o') print("Update list:->",vowel) vowel.remove('a') print("Update list:->",vowel) os=['linux','windows','cobol'] print("Old list:->",os) os.reverse() print("Update list:->",os) OUTPUT: PROGRAM FOR BUILT-IN METHODS OF LIST Old list:-> ['Cat', 'Dog', 'Rabbit'] Updated list:-> ['Cat', 'Dog', 'Rabbit', 'Cow'] Old list:-> ['Python', 'Java', 'C++', 'C'] Updated List:-> ['Python', 'Java', 'C++'] Old list:-> ['e', 'a', 'u', 'o', 'i'] sorted List in Assending order:-> ['a', 'e', 'i', 'o', 'u'] sorted List in Desending order:-> ['u', 'o', 'i', 'e', 'a'] Old list:-> ['a', 'e', 'i', 'u'] Update list:-> ['a', 'e', 'i', 'o', 'u'] Update list:-> ['e', 'i', 'o', 'u'] Old list:-> ['linux', 'windows', 'cobol'] Update list:-> ['cobol', 'windows', 'linux'] Program No.4:Program to Demonstrate use of Dictonary. thisdict={'NAME':'Vishal','PLACE':'Sankeshwar','USN':1711745} print("Dictonary Content=",thisdict) x=thisdict['PLACE'] print("PLACE is:->",x) print("Keys in Dictonary are:") for x in thisdict: print(x) print("Values in this dictonary are:->") for x in thisdict: print(thisdict[x]) print("Both Keys and values of the dictonary are:->") for x,y in thisdict.items(): print(x,y) print("Total items in the dictonary:->",len(thisdict)) thisdict['Distict']='Belagavi' print("Added new item is=",thisdict) thisdict.pop('PLACE') print("After removing the item from dictonary=",thisdict) del thisdict['USN'] print("After deleting the item from dictonary=",thisdict) thisdict.clear() print("Empty Dictonary=",thisdict) mydict=thisdict.copy() print("Copy of Dictonary is=",mydict) OUTPUT: Dictonary Content= {'NAME': 'Vishal', 'PLACE': 'Sankeshwar', 'USN': 1711745} PLACE is:->Sankeshwar Keys in Dictonary are: NAME PLACE USN Values in this dictonary are:-> Vishal Sankeshwar 1711745 Both Keys and values of the dictonary are:-> NAME Vishal PLACE Sankeshwar USN 1711745 Total items in the dictonary:-> 3 Added new item is= {'NAME': 'Vishal', 'PLACE': 'Sankeshwar', 'USN': 1711745, 'Distict': 'Belagavi'} After removing the item from dictonary= {'NAME': 'Vishal', 'USN': 1711745, 'Distict': 'Belagavi'} After deleting the item from dictonary= {'NAME': 'Vishal', 'Distict': 'Belagavi'} Empty Dictonary= {} Copy of Dictonary is= {} Program No.5: Program to Create SQLite Database and Perform Operations on Table. import sqlite3 conn=sqlite3.connect('test.db') cursor=conn.cursor() cursor.execute("create Table empl1(id integer,nametect)") cursor.execute("insert into empl1(id,name)values(101,'Ravi')") cursor.execute("insert into empl1(id,name)values(101,'Ravishannker')") cursor.execute("insert into empl1(id,name)values(101,'Ramresh')") print("Displaying the empl1 table") cursor.execute("select *from empl1") rows=cursor.fetchall() for row in rows: print(row) print("After update and delete the records in the table") cursor.execute("update empl1 set name='Rakesh' where id==101") cursor.execute("delete from empl1 where id=103") print("Displaying the empl1 where id=103") cursor.execute("select *from empl1") rows=cursor.fetchall() for row in rows: print(row) print("Table is dropped") cursor.execute("drop table empl1") conn.commit() cursor.close() conn.close() OUTPUT: Displaying the empl1 table (101, 'Ravi') (101, 'Ravishannker') (101, 'Ramresh') After update and delete the records in the table Displaying the empl1 where id=103 (101, 'Rakesh') (101, 'Rakesh') (101, 'Rakesh') Table is dropped Program No.6: Program to Create a GUI using TKinter module. import tkinter as tk def show_entry_fields(): print("First Name: %s\n Last Name: %s" % (e1.get(), e2.get())) master = tk.Tk() tk.Label(master, text=" GUI ", fg="red", font=('times', 24, 'italic')).grid(row=0) tk.Label(master, text="First Name").grid(row=1) tk.Label(master, text="Last Name").grid(row=2) e1 = tk.Entry(master) e2 = tk.Entry(master) e1.grid(row=1, column=1) e2.grid(row=2, column=1) tk.Label(master, text="Select Gender:", fg="blue").grid(row=3, column=0) R1=tk.Radiobutton(master, text="Male", value=1).grid(row=4, column=0, sticky=tk.W) R2=tk.Radiobutton(master, text="Female", value=2).grid(row=4, column=1, sticky=tk.W) tk.Label(master,text = "Select Age:", fg="blue").grid(row=5, column=0) tk.Spinbox(master, from_= 18, to = 25).grid(row=5, column=1) tk.Label(master, text="Select Subject:", fg="blue").grid(row=6, column=0) tk.Checkbutton(master, text="Java").grid(row=7, column=0, sticky=tk.W) tk.Checkbutton(master, text="Python").grid(row=7, column=1, sticky=tk.W) tk.Checkbutton(master, text="PHP").grid(row=8, column=0, sticky=tk.W) tk.Checkbutton(master, text="C#.Net").grid(row=8, column=1, sticky=tk.W) tk.Label(master,text = "Select District:", fg="blue").grid(row=9, column=0) listbox = tk.Listbox(master) listbox.insert(1,"Belgaum") listbox.insert(2, "Bangalore") listbox.insert(3, "Dharawad") listbox.insert(4, "Hubli") listbox.insert(5, "Mysore") listbox.insert(6, "Mangalore") listbox.grid(row=10,column=1) tk.Button(master, text='QUIT', fg="red", bg="yellow", command=master.quit).grid(row=11, column=0, sticky=tk.W, pady=4) tk.Button(master,text='SHOW', fg="red", bg="yellow", command=show_entry_fields).grid(row=11, column=1, sticky=tk.W, pady=4) tk.mainloop() OUTPUT: First Name: Aditya Last Name: Yadav Program No.7: Program to Demonstrate Exceptions in Python. try: print("TRY BLOCK") a=int(input("Enter a:->")) b=int(input("Enter b:->")) c=a/b except: print("EXCEPT BLOCK") print("We cannot divide by ZERO") else: print("ELSE BBLOCK") print("The division of a and b is:->",c) print("NO EQCEPTION") finally: print("FINALLY BLOCK") print("Out of except,ELSE and FINALY bolcks") OUTPUT: TRY BLOCK Enter a:->15 Enter b:->0 EXCEPT BLOCK We cannot divide by ZERO FINALLY BLOCK Out of except,ELSE and FINALY bolcks TRY BLOCK Enter a:->27 Enter b:->9 ELSE BBLOCK The division of a and b is:-> 3.0 NO EQCEPTION FINALLY BLOCK Out of except,ELSE and FINALY bolcks Program No.8: Program to Drawing Linechart and Barchartusing Matplotlib. import matplotlib.pyplot as plt import numpy as nmpi xpoints=nmpi.array([12,10,20,50]) ypoints=nmpi.array([10,20,28,57]) plt.plot(xpoints,ypoints) xpoints=nmpi.array(['Apple','Doll','Cat','Duck']) ypoints=nmpi.array([23,45,64,30]) plt.bar(xpoints,ypoints) plt.show() OUTPUT: Program No.9: Program to Drawing Histogram and pie chart using matplotlib. import matplotlib.pyplot as mlt student_performance=["excellent","good","average","poor"] student_values=[15,20,40,10] mlt.pie(student_values,labels=student_performance,startangle=90,explode=[0.2,0.1,0,0],shadow=True,colors=["violet","indigo","blue","orange"]) mlt.show() marks=[90,92,40,60,55,44,30,20,10,54,74,82] grade_interval=[0,35,70,100] mlt.title(".......STUDENT......GRADE......") mlt.hist(marks,grade_interval,facecolor="black",rwidth=0.7,histtype="bar") mlt.xticks([0,35,70,100]) mlt.xlabel("P E R C E N T A G E ") mlt.ylabel("No. of STUDENTS...") mlt.show() OUTPUT: Program No.10: Program to create Array using NumPy and Perform Operations on Array. import numpy as np array=np.array([4,3,2,1]) print("Array elements are:->",array) min_value=np.min(array) max_value=np.max(array) mean_value=np.mean(array) print("The Maximum value is:->",min_value) print("The Maximum value is:->",max_value) print("The Mean value is:->",mean_value) array=array+10 print("Add 10 to each element in the array:->",array) array=array*2 print("Multiply each element in the array by 2:->",array) sort=np.sort(array) print("Sorted array:->",sort)