Professional Documents
Culture Documents
Outcome Based Lab Task Report
Outcome Based Lab Task Report
BASED LAB
TASK REPORT
1
COMPUTER PROGRAMMING
Submitted by
SATHYAMANGALAM 638401
MARCH 2021
2
DECLARATION
I affirm that the lab task work titled “ COMPUTER PROGRAMMING ” being
Technology.
3
EXPERIMENT PAGE
No. TITLE No
1 SIMPLE CALCULATOR
1.1 OBJECTIVE 5
1.3 METHODOLOGY 6
1.5 OUTPUT 7
1.6 CONCLUSION 8
1.7 REFERENCE 8
2.1 OBJECTIVE 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
ENTER A NUMBER 1
YES
ENTER A NUMBER 2
YES
NO
NO
YES RESULT=
IF SELECTED OPERATION= 3 NUM1*NUM2
NO
NO
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 :
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