0% found this document useful (0 votes)
24 views7 pages

Niranjanlab 4 Work

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)
24 views7 pages

Niranjanlab 4 Work

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/ 7

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

Techspire College

CT108-3-1

Python Programming

BSc.IT 1st Semester

DATE: 20th December, 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


Lab :- 4

Part A

1. Write a program to check if the given number is even or odd.

def evenodd(num):
if num %2 ==0:
print("even")
else:
print("odd")

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


result= evenodd(num)
print(result)
2. Based on the following table, write a program that determines if your score will pass the exam.

def function(marks):
if marks>50:
print("you passed")

else:
print("you failed")

result = function(60)
3. Write a PYTHON program to find largest of three numbers
4. def function(num1,num2,num3):
5. if num1>num2 and num1>num3:
6. print("largest: ", num1)
7.
8. elif num2>num3 and num2>num1:
9. print("largest: ",num2)
10.
11. else:
12. print("largest: ", num3)
13.
14. result = function(5,3,8)
4. Write a program to display profit or loss in trading of an item.
Sample input/output:
Enter selling price: 20
Enter buying price:19
You have profit in trading of this item

def function(SP,CP):
if SP>CP:
print("you have profit in trading of this item")

else:
print(" you have loss in trading of this item")

result = function(20,19)

Part B
1. . Lecturers often provide scores on tests, which are converted to grades the end of the semester.
Write a python program to ask for the score input and print the respective grade as follow:
2. def function(score):
3. if score>=80:
4. return 'A'
5.
6. elif score>=60 and score<=79:
7. return 'B'
8.
9. elif score>= 40 and score<=59:
10. return 'C'
11. else:
12. return 'D'
13.
14. score = int(input("enter your score: "))
15.
16. result = function(score)
17. print("your grade is " , result)
2. Write a PYTHON program to find smallest of three numbers

def function(num1,num2,num3):
if num1<num2 and num1<num3:
print("smallest: ", num1)

elif num2<num3 and num2<num1:


print("smallest: ",num2)

else:
print("smallest: ", num3)

num1 = int(input("enter your 1st number : "))


num2 = int(input("enter your 2nd number : "))
num3 = int(input("enter your 3rd number : "))
result = function(num1,num2,num3)

3. Write a PYTHON program to check a year is a leap year or not a leap year.

def function(days):
if days == 366:
return 'leaf year'

else:
return 'not leaf year'

days = int(input("enter days in year: "))


result = function(days)
print(result)

4. Write a Python program to determine whether the speed limit exceeds 110 km per hour. If
the speed exceeds 110, then fine = 300, otherwise fine = 0. Display fine.

def function(speed):
if speed == 110:
return 'fine is 300'

else:
return 'fine is 0'

speed = int(input("enter speed "))


result = function(speed)
print(result)
5. Write a Python program to determine whether the age is above 12 years old. If the age is
above 12, then ticket = 20, otherwise ticket = 10. Display ticket.

def function(age):
if age >= 18:
return 'ticket is 20'

else:
return 'ticket is 10'

age= int(input("enter your age : "))


result = function(age)
print(result)

6. Write a PYTHON program to check entered character is vowel or consonant.

vovel = 'aeiouAEIOU'
def function(letter):
if letter in vovel:
return 'vovel'

else:
return 'consonent'

letter = str(input("enter your name "))

result = function(letter)
print(result)
7. A company insures its drivers in the following cases: - If the driver is married. - If the
driver is unmarried, male and above 30 years of age. - If the driver is unmarried, female and above
25 years of age. In all the other cases, the driver is not insured. If the marital status, gender, and age
of the driver are the inputs.

maritalstatus = "married", "unmarried"


gender = "male" , "female"
def insure_or_not(gender, age, maritalstatus):
if maritalstatus == 'married':
return 'insured'
elif maritalstatus == 'unmarried' and gender == 'male' and age>=30:
return ' insured'

elif maritalstatus == 'unmarried' and gender == 'female' and age==25:


return 'insured'

else:
return ' not insured'

maritalstatus = str(input("enter your status married or unmarried: "))

gender = str(input("enter your gender male or female :"))

age = int(input("enter your age: "))

result = insure_or_not(gender,age,maritalstatus)

print(result)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy