python code of 10 july



# Enter your code here. Read input from STDIN. Print output to STDOUT
class Student:
    def init(self,name,sub1,sub2,sub3):
        self.name=name
        self.sub1=sub1
        self.sub2=sub2
        self.sub3=sub3

    def calculateResult(self):
        average=0
        if(self.sub1>=40 and self.sub2>=40 and self.sub3>=40):
            average=(self.sub1+self.sub2+self.sub3)/3
        return average

class School:
    def init(self,name,studentDict):
        self.name=name
        self.studentDict=studentDict

    def getStudentResult(self):
        for i in self.studentDict.keys():
            avg=i.calculateResult()
            if(avg>60):
                self.studentDict[i]="pass"
        return self.studentDict

    def findStudentWithHighestMarks(self,lis):
        if len(lis)==0:
            return None
        else:
            dic2={}
            avg=0
            for i in lis:
                avg=i.calculateResult()
                dic2[i]=avg
            maximum=max(dic2,key=dic2.get)
            return maximum

if(name=="main"):
    n=int(input())
    dic={}
    lis1=[]
    for i in range(n):
        name=input()
        sub1=float(input())
        sub2=float(input())
        sub3=float(input())
        st=Student(name,sub1,sub2,sub3)
        dic[st]="fail"
    school_name=input()
    sc=School(school_name,dic)
    dic=sc.getStudentResult()
    for j in dic:
        if(dic[j]=="pass"):
            lis1.append(j)
    obj=sc.findStudentWithHighestMarks(lis1)
    for k in lis1:
        print (k.name)
    if(obj==None):
        print("No Student Passed")
    else:
        print(obj.name)

JAVA Answer




import java.io.*;
    import java.util.*;
    import java.text.*;
    import java.math.*;
    import java.util.regex.*;

    public class Solution
    {

    public static void main(String[] args)
    {
    Scanner sc = new Scanner(System.in);
    NavalVessel[] nv= new NavalVessel[4];
    for(int i=0; i<4;i++)
    {
        int a = sc.nextInt(); sc.nextLine();
        String b = sc.nextLine();
        int c = sc.nextInt();
        int d = sc.nextInt(); sc.nextLine();
        String e = sc.nextLine();
        nv[i] = new NavalVessel(a,b,c,d,e,"\0");
    }
    int f = sc.nextInt();sc.nextLine();
    String g = sc.nextLine();
    int res = findAvgVoyagesByPct(nv, f);
    if(res>0)
    System.out.println(res);
    else
    System.out.println("There are no voyages completed with this percentage");
    
    NavalVessel tem = findVesselByGrade(nv,g);
    if(tem == null)
    {
        System.out.println("No Naval Vessel is available with the specified purpose");
    }
    else
    System.out.println(tem.vn+"%"+tem.cn);

    

    }

    public static int findAvgVoyagesByPct(NavalVessel[] nv, int p)
    {
        int avg=0,per=0,s=0,c=0;
    for(int i=0;i<4;i++)
    {
        per = ((nv[i].vc*100)/nv[i].vp);
        if(per>=p)
        {
            s=s+nv[i].vc;
            c++; 
        }
    }
    if(c>0)
    {
        avg = s/c;
        return avg;
    }
    else
    return avg;
    }

    public static NavalVessel findVesselByGrade(NavalVessel[] nv, String purpose)
    {
    //method logic
        int rt;
    NavalVessel temp = new NavalVessel();
    for(int i=0;i<4;i++)
    {
        if((purpose.equalsIgnoreCase(nv[i].pp))&&(nv[i].vc<=nv[i].vp))
        {
            rt = ((nv[i].vc)*100)/(nv[i].vp);
            temp = nv[i];
            if(rt==100)
            {
                temp.cn = "Star";
            }
            else if (rt>=80 && rt<=99)
            {
                temp.cn = "Leader";
            }
            else if (rt>=55 && rt<=79)
            {
                temp.cn = "Inspirer";
            }
            else
            {
                temp.cn = "Striver";
            }
            return temp;
        }
    }
        return null;
    }

    }

    class NavalVessel 
    {
    //code to build the class
    int id,vp,vc;
    String vn,pp,cn;

    public NavalVessel()
    {

    }

    public NavalVessel(int id, String vn, int vp, int vc, String pp, String cn)
    {
        this.id = id;
        this.vn = vn;
        this.vp = vp;
        this.vc = vc;
        this.pp = pp;
        this.cn = cn;
    }

    }

3 jul mcq


KYT

1.TRUE

2.ADAPTIVE DESIGN

3.NEVER MAKE UNAUTHORISED....

4.JAMSETI TATA

5.inexperience ....

Bizskill

Current status areas of concern next phase
Paul can be task oriented... 
Plan prepare listen close clarify along
Automated tasks
Synthesize technical business skill

Design

Readability, maintainability ,extensibility

Sales revenue, integrity in business, brand reputation

True
 Minimize coupling and increase cohesion
 
(Lead to success) All option

Ui

Lï tag true
Languages 1.(output)
Mark tag
/*… */
Newspaper article
Will not print anything

String and tostring true

Java

1. int num=1_ and int num= _1
2.float and double not allowed in switch 
3. tip -> not enoughtoo many 
4. 1count
5. 2
Plan b executed
6. Hop
7.takeout
8.start -> code doesn't compile 
9. Furniture -> doesn't compile


SQL
Select city from weather where temperature =29
Order by
5
Select count(distinct city_ID)...
Alter table name modify cln_name

python 26 june code


class Vegetable:
    def __init__(self, name, price, quantity):
        self.name = name
        self.price = price
        self.quantity = quantity
    
#Implement/Define Store class
class Store:
    def __init__(self, storeName, vegList):
        self.storeName = storeName
        self.vegList = vegList
    
    def categorizeVegetablesAlphabetically(self):
        self.vegList.sort(key= lambda x: x.name)
        alpha = list(string.ascii_lowercase)
        ret = {}
        for i in alpha:
            temp = []
            for j in self.vegList:
                if i == j.name[0]:
                    temp.append(j.name)
            if len(temp) >0:
                ret[i] = tuple(temp)
        return ret

    def filterVegetablesForPriceRange(self, minimum, maximum):
        self.vegList.sort(key= lambda x: x.name)
        ret = []
        for i in self.vegList:
            if minimum <= i.price <= maximum:
                ret.append(i.name)
        return ret

#Implement main function , Refer the Instructions in Qn text , which helps you to write main #function"
num = int(input())
temp = []
for i in range(num):
    name = input()
    price = float(input())
    quantity = int(input())
    veg = Vegetable(name.lower(),price,quantity)
    temp.append(veg)
name = input()
a = float(input())
b = float(input())
store = Store(name,temp)
catVegAlpha = store.categorizeVegetablesAlphabetically()
priceList = store.filterVegetablesForPriceRange(a, b)
for keys, value in catVegAlpha.items():
    print(keys)
    for x in value:
        print(x)
print(str(a) + '-' + str(b))
if len(priceList) > 0:
    for x in priceList:
        print(x)
else:
    print("No Vegetable(s) in the given price range")

unix code of 26 june



sort -k3 -n -t "," | 

awk 'BEGIN
 
{FS=","}
 {
 if(($5>=80))

 {
print 

$1"|"$2"|"$3"|"$4"|"$5}}'