0% found this document useful (0 votes)
45 views12 pages

174, Bhargav

The document contains multiple Python code snippets that implement various functions, including checking if three sides can form a triangle, calculating a bill based on food choices and distance, loan eligibility based on account details, and counting specific conditions in lists. Each function prompts user input and outputs results based on the provided data. The document serves as a collection of examples demonstrating different programming concepts and logic.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views12 pages

174, Bhargav

The document contains multiple Python code snippets that implement various functions, including checking if three sides can form a triangle, calculating a bill based on food choices and distance, loan eligibility based on account details, and counting specific conditions in lists. Each function prompts user input and outputs results based on the provided data. The document serves as a collection of examples demonstrating different programming concepts and logic.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

LAB FUNCTIONS :-

(g.bhargav,160121733174)

1) def tri(a,b,c):
if a+b>=c and b+c>=a and a+c>=b:
print("yes")
else:
print("no")
a=int(input("enter side a : "))
b=int(input("enter side b : "))
c=int(input("enter side c : "))
tri(a,b,c)
OUTPUT:-

2)CODE:-
def combinations():
n=int(input("enter no. of combinations : "))
v=0
nv=0
bill=0
t=0
if n<1:
print("no")
bill=-1
print(bill)
else:
for i in range(n):
p=input("enter v for veg and n for non veg : ")
if p=='v':
v+=1
elif p=='n':
nv+=1
else:
bill=-1
print(bill)
t=1
break
if t==0:
bill=(v*120)+(nv*150)
dist=int(input("enter distance : "))
if dist<=3:
bill+=0
elif dist>3 and dist<=6:
bill+=(3*(dist-3))
elif dist>6:
bill+=(6*(dist-6)+9)
else:
print("invalid")
bill=-1
print(bill)
print("total bill is : ",bill)
combinations()
OUTPUT:-

3)CODE:-
def loan():
account_number=input("Enter Account number: ")
if account_number[0]!='1':
print("Invalid Account number.")
elif len(account_number)>4 and len(account_number)<4:
print("Invalid Account number.")
else:
an=int(account_number)
balance=int(input("Enter account balance:"))
if balance<100000:
print("Insuffecient balance.")
else:
loan_type=input("Enter C for Car loan, H for House Loan, B for
business loan: ");
loan_type=loan_type.upper()
if loan_type=='C':
salary=int(input("Enter salary: "))
if salary<25000:
print("Inadequate salary.")
else:
amount=int(input('Enter amount required: '))
if amount>=500000:
print("Exceeded limit.")
else:
emi=int(input("Enter number of EMIS: "))
if emi>36:
print("Too many EMIS.")
else:
print("Loan can be provided.")
print("Account number: ", account_number)
print("Eligible amount: 500000")
print("Amount Requested: ", amount, "EMIS
required: ", emi)
elif loan_type=='H':
salary=int(input("Enter salary: "))
if salary<50000:
print("Inadequate salary.")
else:
amount=int(input('Enter amount required: '))
if amount>=6000000:
print("Exceeded limit.")
else:
emi=int(input("Enter number of EMIS: "))
if emi>60:
print("Too many EMIS.")
else:
print("Loan can be provided.")
print("Account number: ", account_number)
print("Eligible amount: 6000000")
print("Amount Requested: ", amount, "\nEMIS
required: ", emi)
elif loan_type=='B':
salary=int(input("Enter salary: "))
if salary<75000:
print("Inadequate salary.")
else:
amount=int(input('Enter amount required: '))
if amount>=7500000:
print("Exceeded limit.")
else:
emi=int(input("Enter number of EMIS: "))
if emi>84:
print("Too many EMIS.")
else:
print("Loan can be provided.")
print("Account number: ", account_number)
print("Eligible amount: 7500000")
print("Amount Requested: ", amount, "\nEMIS
required: ", emi)
else:
print("Invalid Loan type.")
loan()
OUTPUT:-
4)CODE:-
def hl(head,leg):
if head>=leg:
print("no")
elif leg%2!=0:
print("no")
else:
rc=(leg-2*head)/2
cc=head-rc
print("no. of rabbits : ",int(rc))
print("no. of chickens : ",int(cc))
head=int(input("enter no. of heads : "))
leg=int(input("enter no. of legs : "))
hl(head,leg)
OUTPUT:-
5)CODE:-
def digit_sum(n):
s=0
while n!=0:
rem=n%10
s+=rem
n//=10
return s
def digit_count(n):
c=0
while n!=0:
n//=10
c+=1
return c
def maximum(num1, num2):
if num2<num1:
print("Num2 is lesser than Num1")
else:
l=[]
for i in range(num1, num2+1):
s=digit_sum(i)
c=digit_count(i)
if s%3==0 and c==2 and i%5==0:
l.append(i)
print(max(l))
num1=int(input("ENTER FIRST NUMBER : "))
num2=int(input("ENTER SECOND NUMBER : "))
maximum(num1, num2)
OUTPUT:-

6)CODE:-
def ticketcost(a,c):
t=(a*37550)+(c*37550/3)
t+=(t*0.07)
t-=(t*0.1)
print("Total ticket cost is",t,"Rs")
A=int(input("enter the number of adults :"))
C=int(input("enter the number of children :"))
ticketcost(A,C)
OUTPUT:-

7)CODE:-
global n
n=int(input("Enter number of values in list: "))
def counter(l):
count=0
for i in range(n-1):
if l[i]==l[i+1]:
count+=1
else:
continue
return count
l=[]
for i in range(n):
l.append(int(input("enter elements of the list : ")))
print(counter(l))
OUTPUT:-
)

8)CODE:-
def lyear(year):
count=0
l=[]
while(count<15):
if(year%4==0 or year%400==0 and year%100==0):
l.append(year)
count=count+1
year+=1
return l
yr=int(input("enter a year : "))
l=lyear(yr)
print("The leap years after",yr,"are")
print(l)
OUTPUT:-
10)CODE:-
global n
n=int(input("Enter number of elements in list: "))
def ln(l):
num=""
l=sorted(l)
for x in range(len(l)-1,-1,-1):
num+=str(l[x])
return int(num)
l=[]
for i in range(n):
l.append(int(input("enter element :")))
print(ln(l))
OUTPUT:-

You might also like