0% found this document useful (0 votes)
12 views

NiranjanLab3work

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

NiranjanLab3work

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

(Academic Collaboration with Asia Pacific University of Technology and Innovation, Malaysia)

Techspire College

CT108-3-1

Python Programming

BSc.IT 1st Semester

DATE: December 14th, 2024

Lab Report

Submitted By: Submitted To:

Name: Niranjan ghising BSc.IT Department

Intake: Fall 2024


Table of Contents

S.N. LAB WORKS SIGNATURE REMARKS

1 PROBLEM SOLVING TECHNIQUES

2 PROBLEM SOLVING TECHNIQUES

3 GETTING STARTED WITH PYTHON

4 CONTROL STRUCTURE IN PYTHON –


CONDITIONAL STATEMENT

5 CONTROL STRUCTURE IN PYTHON –


REPETITION STATEMENT

6 FUNCTION IN PYTHON

7 WORKING WITH STRING

8 COLLECTION DATA TYPE - LIST

9 COLLECTION DATA TYPE - TUPLE

10 COLLECTION DATA TYPE – SET AND


DICTIONARY

11 FILE HANDLING IN PYTHON


Part A :
1. Print “Hello”.
Print(“Hello”)

2. Write a program to get an input word from a user. Then, display the given word together with
the sentence of “Welcome, ” as below:
name = input("enter your name: ")
print(" welcome ",name)

3. Write a program to get two inputs from user. Then display the input.
age = int(input("enter your age: "))
print("welcome",name)
print(f"you are {age} years old")

Part B :
1. Accept number from user and display it

#Question NO 1
def function(num):
return num

#input
num = int(input("enter a number :"))

#recall

display = function(num)
print(f" the number is {display}")
2. Accept 2 numbers from user and display addition of it.

#Question NO 2

def fuction(num2,num3):
result= num2+num3
return result

#input

num2 = int(input("enter a number: "))


num3= int(input("enter a number: "))

#recall
final_result = fuction(num2,num3)
print(f"the addition of {num2} and {num3} is {final_result}")

3. Accept 2 input values from user and do arithmetic operation. (+, -, *, /, %).

def function(num1, num2, operand):


if operand== '+':
add = num1 + num2
return add
elif operand == '-':
sub = num1 - num2
return sub
elif operand == '*':
mult = num1 * num2
return mult
elif operand == '/':
divide = num1 / num2
return divide
else:
rem = num1 % num2
return rem

#input
num1 = int((input("enter a number : ")))
num2 = int((input("enter a number: ")))
operand = input(" +, -, *, /, %: ")

#recall
result = function(num1,num2,operand)
print(f"The {operand } of {num1} and {num2} is {result} ")
4. Accept 2 numbers from user and print swapping of those number.
5. #Question NO 4
6.
7. def function(num1,num2):
8. num1,num2= num2,num1
9. return num1,num2
10.
11. #input
12. num1= int(input(" enter a number for num1 : "))
13. num2 = int(input("enter a number for num2 : "))
14.
15. print("********************************************After swapping
************************")
16. #recall
17.
18. num1, num2 = function(num1,num2)
19. print(f"The value of num1 is {num1} and num2 is {num2} ")

5.Accept 5 subject marks from student and calculate the total and percentage(average) of a student for a
semester and display it.

def function(sub1,sub2,sub3,sub4,sub5):
total= sub1 + sub2 + sub3 + sub4 + sub5
avg = total/5
return total,avg

#input
sub1= int(input("enter your 1st subject marks : "))
sub2= int(input("enter your 2nd subject marks : "))
sub3= int(input("enter your 3rd subject marks : "))
sub4= int(input("enter your 4th subject marks : "))
sub5= int(input("enter your 5th subject marks : "))

#recall
result_total= function(sub1,sub2,sub3,sub4,sub5)
result_avg = function(sub1,sub2,sub3,sub4,sub5)
print(f"the total of 5 subjects marks is {result_total} and average is
{result_avg}")
6. Accept Basic from an employee and calculate salary of an employee by considering following things.
(Grade_pay is double of Basic. DA is 70% of Basic. TA is RM 200. HRA is 20% of Basic.)(Formula
for salary = Grade_pay + DA + TA + HRA).

#Question no 6
def function(basic ):
Grade_pay = 2*basic
DA= 0.7*basic
TA = 200
HRA = 0.2*basic
salary = Grade_pay+ DA + TA + HRA
return salary

#input

basic = float(input("enter your basic : "))

#recall

final_salary = function(basic)

print(f"the total salary of the employee is {final_salary:.2f}")

You might also like