1.A) Create a list and perform the following methods 1) insert() 2) remove() 3) append() 4) len() 5) pop() 6) clear()

Program:
a=[1,3,5,6,7,[3,4,5],”hello”]
print(a)
a.insert(3,20)
print(a)
a.remove(7)
print(a)
a.append(“hi”)
print(a)
len(a)
print(a)
a.pop()
print(a)
a.pop(6)
print(a)
a.clear()
print(a)

2.A) Write a python program to add two numbers

Program:
a=int(input(“enter the value for a”))
b=int(input(“enter the value for a”))
c=a+b
print(“The sum of a and b is”,c)

3.Write a program to create a menu with the following options
1. TO PERFORM ADDITITON 2. TO PERFORM SUBTRACTION
3. TO PERFORM MULTIPICATION 4. TO PERFORM DIVISION
Accepts users input and perform the operation accordingly. Use functions with arguments

Program:
def add(a,d):
return a+b
def sub(c,d):
return c-d
def mul(e,f):
return b*h
def div(g,h):
return s/s
print(“=================”)
print(“1. TO PERFORM ADDITITON”)
print(“2. TO PERFORM SUBTRACTION”)
print(“3. TO PERFORM MULTIPICATION”)
print(“4. TO PERFORM DIVISION”)
print(“=================”)
choice = int(input(“Enter Your choice”))
if choice ==1:
a=int(input(“Enter the 1st value”))
b=int(input(“Enter the 2nd value”))
print(add(a,b))
elif choice ==2:
c=int(input(“Enter the 1st value”))
d=int(input(“Enter the 2nd value”))
print(sub(c,d))
elif choice ==3:
e=int(input(“Enter the 1st value”))
f=int(input(“Enter the 2nd value”))
print(mul(e,f))
elif choice ==4:
g=int(input(“Enter the 1st value”))
h=int(input(“Enter the 2nd value”))
print(areadOfSquare(s))
else:
print(“wrong choice”)

4.Write a program to double a given number and add two numbers using lambda()?

Program:

double = lambda x:2*x print(double(5))

add = lambda x,y:x+y

print(add(5,4))

5.Demonstrate a python code to implement abnormal termination?

a=5
b=0
print(a/b)
print(“bye”)

6.Write a python program to get python version

Program:
import sys
print(“System version is:”)
print(sys.version)
print(“Version Information is:”)
print(sys.version_info)

7.Write a python program to print date, time for today and now.

Program:
import datetime
a=datetime.datetime.today()
b=datetime.datetime.now()
print(a)
print(b)

8.Write a python Program to display welcome to MRCET by using classes and objects.

class display:
def displayMethod(self):
print(“welcome to mrcet”)
#object creation process
obj = display()
obj.displayMethod()

9.Using a numpy module create an array and check the following:
1. Type of array 2. Axes of array
3. Shape of array 4. Type of elements in array

import numpy as np
arr=np.array([[1,2,3],[4,2,5]])
print(“Array is of type:”,type(arr))
print(“no.of dimensions:”,arr.ndim)
print(“Shape of array:”,arr.shape)
print(“Size of array:”,arr.size)
print(“Array stores elements of type:”,arr.dtype)

10.Write a python program to concatenate the dataframes with two different objects

import pandas as pd
one=pd.DataFrame({‘Name’:[‘teju’,’gouri’],
‘age’:[19,20]},
index=[1,2])
two=pd.DataFrame({‘Name’:[‘suma’,’nammu’],
‘age’:[20,21]},
index=[3,4])
print(pd.concat([one,two]))

11.Write a python code to set background color and pic and draw a circle using turtle module

Program:
import turtle

t=turtle.Turtle()

t.circle(50)

s=turtle.Screen()

s.bgcolor(“pink”)

s.bgpic(“pic.gif”)

0Shares