devil

Python Programming Lab

PART-A


Program No.1: Program to check if a number belongs to the Fibonacci Sequence.

N = int(input("Enter a number : "))

f3 = 0
f1 = 1
f2 = 1

if ( N == 0 ) or ( N == 1 ) :
    print("The given number belongs to fibonacci series")
else :
    while f3 < N :
        f3 = f1 + f2
        f2 = f1
        f1 = f3

    if f3 == N :
        print("The given number belongs to fibonacci series")
    else :
        print("The given number does not belong to fibonacci series")


OUTPUT:
Enter a number : 5
The given number  belongs to fibonacci series

Enter a number : 17
The given number does not belongs to fibonacci series




Program No.2: Program to solve Quadratic Equations.
import math
def findRoots ( a, b, c ) :
    
    D = b * b - 4 * a * c

    if D > 0:
        print(" real and different roots ")
        print((-b + sqrt ( D )) / (2 * a))
        print((-b – sqrt ( D )) / (2 * a))

    elif  D == 0 :
        print(" real and same roots")
        print( -b / (2 * a) )

    else :
        sqrt_val = math.sqrt(abs(D))/ ( 2 * a )
        print("Complex Roots")
        print(- b / (2 * a), " + i", sqrt_val)
        print(- b / (2 * a), " - i", sqrt_val)

# a, b, c = int(input(‘ Enter coefficients : ‘).split()
a = int(input('Enter a : '))
b = int(input('Enter b : '))
c = int(input('Enter c : '))

if a == 0:
    print("Input correct quadratic equation")

else:
    findRoots (a, b, c)

OUTPUT- 1: OUTPUT- 2:

Enter a : 2
Enter b : 5
Enter c : 7
Complex Roots
-1.25  + i 1.3919410907075054
-1.25  - i 1.3919410907075054
Enter a : 1
Enter b : 2
Enter c : 1
 real and same roots
-1.0

Program No.3: Program to find the sum of n natural numbers.
num = int ( input (" Enter a number :  "))

dupl = num

if num < 0 :
    print(" Enter a positive number  ")

else:
    sum = 0
    while ( num  >  0 ) :
       sum += num
       num -= 1


    print(f"The sum of {dupl} natural number is ", sum)

OUTPUT:
Enter a number :  -5
Enter a positive number 

Enter a number :  10
The sum of 10 natural number is  55








Program No.4: Program to Display Multiplication Table.
num = int ( input (" Enter a number : "))

print(f"Table of { num } is : ")

for a in range ( 1 , 11):
   print(num,'x',a,'=',num*a)

OUTPUT:
Enter a number : 9
Table of 9 is : 
9 x 1 = 9
9 x 2 = 18
9 x 3 = 27
9 x 4 = 36
9 x 5 = 45
9 x 6 = 54
9 x 7 = 63
9 x 8 = 72
9 x 9 = 81
9 x 10 = 90







Program No.5: Program to check if a given number is a prime Number or not.
num = int(input("Enter a number: "))

flag = False

if num == 1:
    print(num, "is not a prime number")

elif num > 1:
    for i in range(2, num):
        if (num % i) == 0:
            flag = True
            break

    if flag:
       
  print(num, "is not a prime number")

    else:
        print(num, "is a prime number")

OUTPUT:
Enter a number: 7
7 is a prime number

Enter a number: 6
6 is not a prime number







Program No.6: Program to Implement a Sequential-Search.
from array import *

def linear_Search(A, N, key):
    for i in range(0, N):
        if (A[i] == key):
            return i
    return -1

# Main Method Bigins Here…
A = array('i',[])

N = int(input("Enter the total number of elements of an ARRAY : " ))

print(f"Enter { N } integer elements of an ARRAY")

for i in range(N):
    A.append(int(input()))

key=int(input("Enter the KEY element to be searched : "))

res = linear_Search(A, N, key)
if(res == -1):
    print(key, " Element not found")
else:
    print(key, " Element found at index: ", res)
OUTPUT:
Enter the total number of elements of an ARRAY : 5
Enter 5 integer elements of an ARRAY
1
4
8
2
-5
Enter the KEY element to be searched : -5
Element found at index:  4
……………………………………………………………………………………………………………………….
Enter the total number of elements of an ARRAY : 4
Enter 4 integer elements of an ARRAY
3
1
6
5
Enter the KEY element to be searched : -4
Element not found


Program No.7: Program to create simple calculator functions.

def calculator (x , i , j ):
    switcher = {
        1: ( i + j ),
        2: (i - j),
        3: (i * j),
        4: (i / j),
        }

    print ( switcher.get (x, "wrong input"))



print("...........SIMPLE CALCULATER............")
print ("1. Addition")
print ("2. Subtraction")
print ("3. Multiplication")
print ("4. Division")
x = input ("Please enter your action :--> ")
i = input ("Please enter first number :--> ")
j = input ("Please enter second number :--> ")
calculator (int(x) , int(i) , int(j))

OUTPUT:
...........SIMPLE CALCULATER............
1. Addition
2. Subtraction
3. Multiplication
4. Division
Please enter your action :--> 2
Please enter first number :--> 5
Please enter second number :--> 9
-4


Program No.8: program to Explore String Functions.
str1 = input ("Enter first string:-->")
str2 = input ("Enter second string:-->")
print("Conversion of uppercase of", str1, "is" , str1.upper() )
print("Conversion of lowercase of", str2, "is" , str2.lower() )
print("Swap-case of string", str1, "is", str1.swapcase())
print("The cased version of string", str1, "is", str1.title())
print("String replacement of first string", str1, "to", str1.replace(str1 , str2))
string = "Python is awesome"
capitalized_string  = string.capitalize()
print("old string :-> ", string)
print("Capitalized string is :-> " , capitalized_string)
string = "Python is awesome, isnt it?"
substring = "is"
count = string.count(substring)
print("The count of given string is:->", count)
name = "bcacollege,nidasoshi"
if name.isalpha() == True:
print("All characters are alphabates")
else:
print("All characters are not alphabates")
print("Maximum is :-> ",max(1,3,2,5,4))
num=[1,3,2,8,5,10,6]
print("The maximum number in given array is:->", max(num))
teststring = "Python"
print("Length of",teststring,"is :-> ", len(teststring))



OUTPUT:
Enter first string :--> computer
Enter second string :--> APPLICATION
Conversion of uppercase of computer is COMPUTER
Conversion of lowercase of APPLICATION is application
Swap-case of string computer is COMPUTER
The cased version of string computer is Computer
String replacement of first string computer to APPLICATION
old string :-> Python is awesome
Capitalized string is :-> Python is awesome
The count of given string is :-> 2
All characters are not alphabates
Maximum is :-> 5
The maximum number in given array is :-> 10
Length of Python is :-> 6








Program No.9: Program to Implement Selection sort.
from array import*
N = int(input("Enter size of an array:--> "))

A = array('i',[])
print("Enter array elements:-->")
for i in range(N):
    A.append(int(input()))

for i in range(0,len(A)-1):
    for j in range(i+1,len(A)):
        if A[i]>A[j]:
            temp=A[i]
            A[i]=A[j]
            A[j]=temp

print("The content of an array after sorting is : ")
for i in range(N):
    print(A[i])

OUTPUT:
Enter size of an array :--> 5

Enter array elements :-->
4
2
7
0
-2

The content of an array aft er sorting is :

-2
0
2
4
7




Program No.10: Program  to Implement Stack.
def create_stack():
    stack = list()
    return stack

def Isempty(stack):
    return len(stack) == 0

def push(stack,n):
   stack.append(n)
   print("pushed item ",n)

def pop(stack):
   if(Isempty(stack)):
       return"Stack is Empty"
   else:
       return stack.pop()

def show(stack):
    print("The stack elements are:")
    for i in stack:
        print(i)

stack=create_stack()
push(stack, str(10))
push(stack, str(20))
push(stack, str(30))
push(stack, str(40))
show(stack)
print("Popped item "+pop(stack))
show(stack)
OUTPUT:
Pushed item 10
Pushed item 20
Pushed item 30
Pushed item 40
The stack elements are:
10
20
30
40
Popped item 40
The stack elements are:
10
20
30


Program No.11: Program to Read and Write into a file.

file1 = open("myfile.txt","w")

L=["This is Delhi \n","This is Paris \n","This is Londan \n"]

file1.write("Hello \n")
file1.writelines(L)
file1.close()

file1=open("myfile.txt","r+")
print("Output of Read Function is")
print(file1.read())

file1.seek(0)
print("Output of Readline Function is")
print(file1.readline())

file1.seek(0)
print("Output of Read(9) Function is")
print(file1.read(9))

file1.seek(0)
print("Output of Readline(9) Function is")
print(file1.readline(9))

file1.seek(0)
print("Output of Readlines Function is")
print(file1.readlines())
file1.close()











OUTPUT:  NOTE  :---( Open “myfile.txt” file by searching it and  SHOW that in Notepad 
Output of Read Function is
Hello 
This is Delhi 
This is Paris 
This is Londan 

Output of Readline Function is
Hello 

Output of Read(9) Function is
Hello 
Th
Output of Readline(9) Function is
Hello 

Output of Readlines Function is
['Hello \n', 'This is Delhi \n', 'This is Paris \n', 'This is Londan \n']














Python Programming Lab

PART-B






Program No.1: Program to Demonstrate usage of basic regular expression.
import re
str = "The rain in spain"
x = re.findall("ai",str)
print("Search of string 'ai': ",x)
x = re.search("\s" ,str)
print("The first white-space character is located in position : ",x.start())

x = re.split("\s",str,1)
print("Split the string in the occurrence of first white-space:",x)

x = re.sub("\s","9",str)
print("Each white-space is replaced with 9 digit: ",x)
print("----------------------------------------------")

x = re.findall("[a-m]",str)
print("The letters in between a to m in the string:",x)

x = re.findall("spain$",str)
if(x):
    print("\n", str, ": Yes, this string ends with 'spain' word ")
else:
    print("\n No match ")

x = re.findall("^The",str)
if(x):
    print("\n",str,": Yes, this string starts with 'The' word")
else:
    print("\n No match")
str1 = "The rain in spain falls mainly in the plain"
x = re.findall("aix*",str1)
print("\n All ai matching characters:",x)

if(x):
    print("Yes, there is atleast one match")
else:
    print("No match")

x = re.findall("al{2}",str1)
print("\n The string which contains 'all':",x)
if(x):
    print("Yes, there is atleast one match")
else:
    print("No match")

str2 = "That will be 59 dollars"
x = re.findall("\d",str2)
print("\n Digits in the string:",x)
x = re.findall("do...rs",str2)
print("\n Dot meta character matches any character:",x)



  OUTPUT:
Search of string 'ai':  ['ai', 'ai']
The first white-space character is located in position :  3
Split the string in the occurrence of first white-space: ['The', 'rain in spain']
Each white-space is replaced with 9 digit:  The9rain9in9spain
----------------------------------------------
The letters in between a to m in the string: ['h', 'e', 'a', 'i', 'i', 'a', 'i']

 The rain in spain : Yes, this string ends with 'spain' word 

 The rain in spain : Yes, this string starts with 'The' word

 All ai matching characters: ['ai', 'ai', 'ai', 'ai']
Yes, there is atleast one match

 The string which contains 'all': ['all']
Yes, there is atleast one match

 Digits in the string: ['5', '9']

 Dot meta character matches any character: ['dollars']






Program No.2: Program to Demonstrate use of advanced regular expressions for data validation.
import re

def validate_password(password):
    regular_expression = "^(?=.*[a-z])(?=.*[A-
Z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!#%*?&]{6,20}$"

    pattern = re.compile(regular_expression)

    valid = re.search(pattern, password)

    if valid:
        print("Password is valid.")
    else:
        print("Password is invalid.")

# main method starts HERE…..

list_of_passwords = ['Abc@123', 'abc@123',
                     'ABC@123', 'Abc@xyz', 'abc123', '12@#$%Abc',
                     'Ab@1', "AAAAAbbbbbcccccc@#$%123456789"]
for i in list_of_passwords:
    print(i, ":"), validate_password(i)

OUTPUT:
Abc@123 :
Password is valid.
abc@123 :
Password is invalid.
ABC@123 :
Password is invalid.
Abc@xyz :
Password is invalid.
abc123 :
Password is invalid.
12@#$%Abc :
Password is valid.
Ab@1 :
Password is invalid.
AAAAAbbbbbcccccc@#$%123456789 :
Password is invalid.


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 Dictionary.
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.keys():
    print(x)
print("Values in this dictonary are:->")

for x in thisdict.values():
    print(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['District'] = '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)

thisdict = {‘Place’ : ‘Sankeshwar’}
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, 'District': '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= {‘Place’ : ‘Sankeshwar’}


Program No.5: Program to Create SQLite Database and Perform Operations on Table.
import sqlite3

conn = sqlite3.connect("test1.db")

curs = conn.cursor()

curs.execute("create table if not exists emp10(id integer,name text)")

curs.execute("insert into emp10(id,name) values(101,'Hari')")
curs.execute("insert into emp10(id,name) values(102,'Ravi')")
curs.execute("insert into emp10(id,name) values(103,'Shashi')")

print("Displaying the emp10 table")
curs.execute("select *from emp10")
rows = curs.fetchall()
for i in rows:
    print (i)

curs.execute("update emp10 set name='Hari-Om' where id=101")
curs.execute("delete from emp10 where id=103")

print("Displaying the emp10 table..AFTER UPDATE & DELETE")
curs.execute("select *from emp10")
rows = curs.fetchall()
for i in rows:
    print (i)

#curs.execute("truncate  emp10")
curs.execute("drop table emp10")
conn.commit()

curs.close()
conn.close()


OUTPUT:
Displaying the emp5 table
(101, 'Ravi')
(101, 'Ravishannker')
(101, 'Ramresh')

After update and delete the records in the table

Displaying the emp5 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.destroy).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 BLOCK")
    print("The division of a and b is :-> ",c)
    print("NO EXCEPTION")

finally:
    print("FINALLY BLOCK")
    print("Out of except,ELSE and FINALLY BLOCK")

OUTPUT-1:
TRY BLOCK
Enter a :-> 10
Enter b :-> 2
ELSE BLOCK
The division of a and b is :->  5.0
NO EXCEPTION
FINALLY BLOCK
Out of except,ELSE and FINALLY BLOCK

OUTPUT-2:I 12
TRY BLOCK
Enter a :-> 10
Enter b :-> 0
EXCEPT BLOCK
We cannot divide by ZERO
FINALLY BLOCK
-1356799  0.Out of except,ELSE and FINALLY BLOCK

Program No.8: Program to Draw Line chart and Bar chart using Matplotlib.
import matplotlib.pyplot as plt    # from matplotlib import pyplot as plt
import numpy as nmpi

x = nmpi.arange(1,11)

y1 = 2 * x
y2 =3 * x

plt.subplot(2,2,1)
plt.title("LINE CHART...", color="blue")

plt.grid()
plt.xlabel("X-Labels",color="red")
plt.ylabel("Y-Labels",color="violet")
plt.plot(x,y1,color='green',linewidth=5)

plt.subplot(2,2,2)
plt.plot(x,y2,color='indigo',linewidth=3, linestyle=":")

students = list(["AMit","Raj","Suraj","Kishan"])
marks = list([60,90,45,6])
plt.subplot(2,2,3)
plt.grid()

plt.title("BAR CHART...", loc='right',color="blue")
plt.bar(students,marks,color="red")
#plt.bar(students,marks)


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.subplot(1,2,1)
mlt.pie(student_values,labels=student_performance,startangle=90,explode=[0.2,0.1,0,0],shadow=True,colors=["violet","indigo","blue","orange"])


marks=[90,92,40,60,55,44,30,20,10,54,74,82]
grade_interval=[0,35,70,100]
mlt.subplot(1,2,2)

mlt.title(".......STUDENT......GRADE......")
mlt.hist(marks,grade_interval,facecolor="cyan",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
A=np.array([4,3,2,1])
print("Array elements are:->",A)

min_value=np.min(A)
max_value=np.max(A)
mean_value=np.mean(A)
print("The Maximum value is:->",min_value)
print("The Maximum value is:->",max_value)
print("The Mean value is:->",mean_value)

A = A + 10
print("Add 10 to each element in the array:->",A)

A = A*2
print("Multiply each element in the array by 2:->",A)

SA=np.sort(A)
print("Sorted array in ASCENDING ORDER:->",SA)
print("Sorted array in DESCENDING ORDER:->",np.sort(A)[::-1])

OUTPUT:
Array elements are:-> [4 3 2 1]
The Maximum value is:-> 1
The Maximum value is:-> 4
The Mean value is:-> 2.5
Add 10 to each element in the array:-> [14 13 12 11]
Multiply each element in the array by 2:-> [28 26 24 22]
Sorted array in ASCENDING ORDER:-> [22 24 26 28]
Sorted array in DESCENDING ORDER:-> [28 26 24 22]



Program No.11: Program to Create DataFrame from Excel sheet using Pandas and Perform Operations on DataFrames.
import pandas as pd

#Create an EXCEL file “MY1.xlsx” and save it into your Project Path

data = pd.read_excel('MY1.xlsx')

print("\n** displaying data from dataframes**\n")
print(data)

print("\n**OPERATING ON DATAFRAMES**\n")

print("\n1.View the first few rows of the dataframes:")
print(data.head())


print("\n2.Number of rows and columns in the data frames:",end=" ")
print(data.shape)

print("\n3.Filtered data(Age column < 20):")
filtered_data = data[data['Age'] < 20]
print(filtered_data)

print("\n4.Sort dataframes based on'Age' col in ascending order:")
sorted_data = data.sort_values(by = 'Age', ascending = True)
print(sorted_data)
print("\n program closed...")

** displaying data from dataframes**

   Empl-Id      Name  Age  Salary      Country
0      101    Shilpa   16   25000          USA
1      102    Rajesh   17   12000  SwitzerLand
2      103   Akshata   20   45000       London
3      104   Gayatri   18   50000      Germany
4      105    Ganesh   32   60000    Australia
5      106   Ashwini   22  123456       Russia
6      107  Sangeeta   16   88888       Africa

**OPERATING ON DATAFRAMES**

1.View the first few rows of the dataframes:

   Empl-Id     Name  Age  Salary      Country
0      101   Shilpa   16   25000          USA
1      102   Rajesh   17   12000  SwitzerLand
2      103  Akshata   20   45000       London
3      104  Gayatri   18   50000      Germany
4      105   Ganesh   32   60000    Australia

2.Number of rows and columns in the data frames: (7, 5)

3.Filtered data(Age column<20):

   Empl-Id      Name  Age  Salary      Country
0      101    Shilpa   16   25000          USA
1      102    Rajesh   17   12000  SwitzerLand
3      104   Gayatri   18   50000      Germany
6      107  Sangeeta   16   88888       Africa

4.Sort dataframes based on'Age' col in ascending order:
   Empl-Id      Name  Age  Salary      Country
0      101    Shilpa   16   25000          USA
6      107  Sangeeta   16   88888       Africa
1      102    Rajesh   17   12000  SwitzerLand
3      104   Gayatri   18   50000      Germany
2      103   Akshata   20   45000       London
5      106   Ashwini   22  123456       Russia
4      105    Ganesh   32   60000    Australia

 program closed...

Popular posts from this blog

A2 python

html