You are on page 1of 13

OUTCOME

BASED LAB
TASK REPORT

1
COMPUTER PROGRAMMING

OUTCOME BASED LAB TASK REPORT

Submitted by

STUDENT NAME: GOKUL R


STUDENT ROLL NO: 202IT134

BANNARI AMMAN INSTITUTE OF TECHNOLOGY

(An autonomous institution affiliated to Anna University, Chennai)

SATHYAMANGALAM 638401

MARCH 2021

2
DECLARATION

I affirm that the lab task work titled “ COMPUTER PROGRAMMING ” being

submitted as the record of original work done by us under the guidance of

Dr.V.Eswaramoorthy, Assistant Professor, Department of Information

Technology.

Student Name : Gokul R

Student Roll No. : 202IT134

I certify that the declaration made above by the candidates is true.


Dr.V.Eswaramoorthy

3
EXPERIMENT PAGE
No. TITLE No

1 SIMPLE CALCULATOR

1.1 OBJECTIVE 5

1.2 BLOCK DIAGRAM 5

1.3 METHODOLOGY 6

1.4 CODING 6-7

1.5 OUTPUT 7

1.6 CONCLUSION 8

1.7 REFERENCE 8

2 SIMPLE SHOPPING ADD TO CART

2.1 OBJECTIVE 9

2.2 BLOCK DIAGRAM 9

2.3 METHODOLOGY 10

2.4 CODING 10 - 12

2.5 OUTPUT 13

2.6 CONCLUSION 13

2.7 REFERENCE 13

4
SIMPLE CALCULATOR – USING PYTHON PROGRAMMING:

1.1 OBJECTIVE:
To Develop a simple calculator, displaying the different arithmetical operations i.e.
addition, subtraction, multiplication and division using python programming language.
1.2 BLOCK DIAGRAM:

START

SELECT THE OPERATION

ENTER A NUMBER 1

IF NUMBER NO INVALID INPUT

YES

ENTER A NUMBER 2

IF NUMBER NO INVALID INPUT

YES

IF SELECTED OPERATION= 1 YES RESULT= NUM1


+NUM 2

NO

IF SELECTED OPERATION= 2 YES RESULT = NUM1-


NUM2

NO

YES RESULT=
IF SELECTED OPERATION= 3 NUM1*NUM2

NO

IF SELECTED OPERATION= 4 YES RESULT=


NUM1/NUM2

NO

IF THE SELECTED RESULT= NO


OPERATION =5 CALCULATION

OUTPUT

5
1.3 METHODOLOGY:
 Ask the user for input for calculation.
 Validate the user’s input is a number.
 Prompts the user to select an operation.
1.Addition
2.Subtraction
3.Multiplication
4.Division
5.No Calculation
 If the user chooses the operation which is not in display, it should display the message
invalid input and stop the program execution.
 If the user chooses the operation 5, the program must display the message “no
calculation” and stop the program execution.

1.4 CODING:
def add(a,b):
return(a+b)
def sub(a,b):
return(a-b)
def multiply(a,b):
return(a*b)
def divide(a,b):
return(a/b)
print('''Select the type of operation need to be performed:'\n'1.Addition '\n'2.Subtraction
'\n'3.Multiplication '\n'4.Division'\n'5.No Calculation''')
operation=int(input('Enter operation 1/2/3/4/5='))
if operation in (1,2,3,4,5):
num1=int(input('Enter a='))
num2=int(input('Enter b='))
if operation ==1:
print('Sum =',add(num1,num2))
6
elif operation ==2:
print('Difference=',sub(num1,num2))
elif operation ==3:
print('Product=',multiply(num1,num2))
elif operation==4:
print('Division=',divide(num1,num2))
elif operation==5:
print('No calculation')
else:
print('Invalid input')

1.5 OUTPUT:

7
1.6 CONCLUSION:
Using python IDLE, the program for “Simple Calculator” is developed and the
program has been executed successfully.
1.7 REFERENCE:
http://greenteapress.com/thinkpython3/

8
2.SIMPLE SHOPPING ADD TO CART:

2.1 OBJECTIVE:
To develop a simple shopping add to cart program to add, update, delete, remove
the duplicates items from the cart.
2.2 BLOCK DIAGRAM:

9
2.3 METHODOLOGY:
1. Store and display the available items and its price using dictionary.
2. Ask the user for first name and last name separately.
3. Add the items to the shopping cart using list.
4. User can update and delete the particular items in the cart.
5. If item already exist in the list remove the duplicate items using set.
6. Store unique items (after removing duplicates) in the tuple.
7. Display the message as “Final Items added to the cart by “user name (combined
first and last name” “display items added to cart”
E.G. Final Items added to the cart by ram is apple, orange.
8. Display the total amount for the items added in the cart.
E.G. Total amount for the items in the cart is 4000.

2.4 CODING :

dict={"MAC": 4," HP": 9,"DELL" : 6, "ACER":5, "LG":2, "LNVO":5, "ROUTER":2}


print(dict)
name1=input("Enter your first name: ")
name2=input("Enter your second name: ")
a=int(input("Enter no. of items to be added: "))
b=[]
for i in range(a):
print("Enter cart item {}:".format(i+1))
p=input()
b.append(p)
print("These are the items in your cart")
print(b)
print("If you want to delete items in your cart \n")
choice=input("Enter Y if you need to delete else enter N :" )
if choice=="Y":
dlt=input("Enter which item to be deleted : ")
10
if dlt == "MAC":
b.remove("MAC")
print("Your cart after removing ",dlt)
print(b)
if dlt=="HP":
b.remove("HP")
print("Your cart after removing ",dlt)
print(b)
if dlt == "DELL":
b.remove('DELL')
print("Your cart after removing ",dlt)
print(b)
if dlt == "ACER":
b.remove("ACER")
print("Your cart after removing ",dlt)
print(b)
if dlt == "LNVO":
b.remove("LNVO")
print("Your cart after removing ",dlt)
print(b)
if dlt == "ROUTER":
b.remove("ROUTER")
print("Your cart after removing ",dlt)
print(b)

elif choice=="N":
print("No items removed")
choice_1= input("Enter Y if you need to add items to your cart else enter N :" )
e=[]
if choice_1=="Y":
c=int(input("Enter number of items to be added: "))
11
for i in range(c):
print("Enter cart item {} to be added :".format(i + 1))
d = input()
e.append(d)
if choice_1 == "N":
print("No changes in your cart")
print("Your added items ",e)
print("Items in your cart")
b.extend(e)
print(b)
setb=set(b)
print("Final Items added to the cart by ",name1,name2,"are",setb)
f=[]
for i in b:
f.append(dict[i])
print(sum(f))

2.5 OUTPUT:

12
2.6 CONCLUSION :
Using python IDLE, the program for “Simple Shopping Add to Cart” is developed
and the program has been executed successfully.
2.7 REFERENCE:
http://greenteapress.com/thinkpython3/

13

You might also like