top of page
Home: Blog2
Writer's pictureAnuj Yadav

OPA Solution for Unix, Python 15-05-2020

UNIX Solution:(15 marks)

There was only one question. There were 20 minutes allocated for this section.





Solution:


cat $1 > file.txt 
min=`sed '1d' file.txt|sort -nt ',' -k3|head -1|cut -d ',' -f3` 
sed '1d' file.txt|cut -d',' -f3 file.txt| grep -wc $min

Python Solution:(35 marks)

There was only one OOPs question. There were 50 minutes allocated for this section.









class P:
	def __init__(self,pid,pname,sd):
		self.pid=pid
		self.pname=pname
		self.sd=sd
class U:
	# def __init__(self):
	# 	pass
	def g(self,l,id):
		sum=0
		for i in l:
			if i.pid==id:
				for k in i.sd:
					sum=sum+i.sd[k]
		return sum
			# print(i.pname)
		
	def s(self,l,n):
		h=0
		res=None
		for i in l:
			for j in i.sd:
				if j.lower()==n.lower():
					if i.sd[j]>h:
						h=i.sd[j]
						res=i
		return res
		
n=int(input())
l=[]
for i in range(n):
	pid=int(input())
	pname=input()
	k=int(input())
	d=dict()
	for j in range(k):
		s=input()
		e=int(input())
		d[s]=e
	# print(d)
	o=P(pid,pname,d)
	l.append(o)
id=int(input())
n=input()
temp=U()
print(temp.g(l,id))
k=temp.s(l,n)
if k is None:
	print(k)
else:
	print(k.pid,k.pname,k.sd,end="")

11 views0 comments

Recent Posts

See All

Comments


Home: Subscribe

CONTACT

 Kanpur, India

8299229032

  • twitter

Thanks for submitting!

Home: Contact
bottom of page