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}}'




unix code 19 june


#!/bin/bash
sort -k3 -n -t "," |
awk 'BEGIN {FS=","};
if(($5>80 && $5>$4)) 
{
print $1 "|" $2 "|" $3 "|" $4 "|" $5 "|" $6}}'

java code 19 june



import java.util.Scanner;
public class Solution {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        
        AutonomousCar[] cars = new AutonomousCar[4];
        for(int i=0;i<4;i++)
        {
            cars[i] = new AutonomousCar();
            cars[i].carId = s.nextInt();s.nextLine();
            cars[i].brand = s.nextLine(); 
            cars[i].noOfTestConducted = s.nextInt();
            cars[i].noOfTestPassed = s.nextInt(); s.nextLine();
            cars[i].enviorment = s.nextLine();
            
        }
        
        String env = s.nextLine();
        String brand = s.nextLine();
        
        int totalTestPassed = findTestPassedByEnv(cars,env); 
        
      if(totalTestPassed>0)
      {
          System.out.println(totalTestPassed);
      }
      else 
          System.out.println("There are no tests passed in this particular environment");
        
       AutonomousCar car =  updateCarGrade(cars,brand);
       
       if(car!=null)
       {
           System.out.println(car.brand+"::"+car.grade);
       }
       else
           System.out.println("No Car is available with the specified brand");
       
       
       
       
    }

  public static AutonomousCar updateCarGrade(AutonomousCar[] cars, String brand) {
        AutonomousCar car = null;
        
          for(int i =0;i<4;i++)
          {
              if(cars[i].brand.equals(brand))
              {
                  int rating = ((cars[i].noOfTestPassed*100)/cars[i].noOfTestConducted);
                  car = cars[i];
                  if(rating>= 80)
                    car.grade ="A1";
                  else 
                      car.grade = "B2";
              }
          }
        return car;
    }

    public static int findTestPassedByEnv(AutonomousCar[] cars, String env) {
        
        int testPassed = 0;
        
        for(int i=0;i<cars.length;i++)
        {
            if(cars[i].enviorment.equalsIgnoreCase(env))
            {
                testPassed = testPassed+cars[i].noOfTestPassed;
            }
        }    
        return testPassed;
    }

}

class AutonomousCar {
  int carId;
  String brand;
  int noOfTestConducted;
  int noOfTestPassed;
  String enviorment;
  String grade;
}

Algorithm


​1.Fastest Sorting alogithm ?
Ans:Merge
2.which is the not dynamic programming ?
Ans: Primes algorithm

​​3.Which algorithm will gives best performance 
when array is half or almost sorted ?
Ans:  Insertion sort
​​

4.To sort the records from large to small number 
and print the largest number ?
Ans: Option with Desc limit 1


5. Algorithm category.. ?
Ans : Minimum coupling and increase cohesion

html


1.All html tags have closing tags ?
Ans: false

2. which is the invalid field in HTML5 ?
Ans : Day

3. Which is invalid escape sequence in javascript ?

Ans : /e

4. a:link,a:visited {
background-color : red;
}
a:hover {
background-color : green
}
<a href = "abc.html">Click me </a>


Ans:will create a link having background color
 red and on moving the pointer background color
 will be green



5.what is command for order list with roman number ?
Ans: <ol type='I'>
​6.Which is not css unit ?
Ans: ut

7.<p>top news </p>
<blockquote url: hindu  news…. Com</blockquote>

Todays news block quote display or not ?


Ans : True


8.Which tag is used to emphasize the text.. ?
Ans : <emph> or <em>

9. p{
      color:green
     }
     <p>xyz</p>
     Paragraph is printed in which color

Ans :Green
10. Emphasing the text in html … ?

Ans : <em>

11. Tag which is not for formatting text ?

Ans : <p>

12.Syntax of background image in css ?
Ans: background-image

KYT PA

PA Previous Mcq's 

 .Tcs had won the mega partner excellence award in ?
ANS:   2018


.Two A's of effective writing ?

Ans: accurate and accessible
.Details provided in the signature of email ?
Options
  1.  Name email      2.phone number     3. Role       4.   address

Ans : 1,2,3
​​
.Some challenges in Artifical Intelligence ?
Options
  1.  cost  2.  common sense  3.Technology 4 All


Ans : 4

.To copy two files in a new files ?
Ans: cat file1 file 2 > file 3


.Cloud computing provides virtual and storage
 adta. They can access our data or not ?
Ans: True
. if[-r & 2]
Ans: is which contains right expresion in options


. To remove a folder  which have a files
Ans: rm –rf



.String ‘llp’ file case insensitive.. ?

Ans : Grep –i ‘llp’ file.txt




. Being objective in writing skills means

1.Figuring out accurate facts and something
2.Figuring out facts but not personal views
3.Assuming stereotypical information

Ans: 1,2



. While making the help document for the ABC
 application or something which factors should be in
 consideration ?

Options

  1. User experience      
  2. Technical knowledge      3.Gender      
  3.  …

Ans : 1,2,4



. Judging others based on our culture.. ?

Ans : Ethnocentrism


. Rio weekly celebrate because … ?

Ans : Aimed to improve System support operation

. Computer algorithm which learns using  previous
 result .. ?

Options

Ans : Classification


. The production logs can be shared with the
 concerned team after appropriate ?
Ans :Approval

. Duplication of code is the root cause of problem in
 dp ?

Ans : True

 What is difference between private and public cloud ?
 Ans : Deployment location


. which of the method is used by humans while 
making judgements ?

Ans : Intuitive based


. The field that investigates in intelligence is
Ans : Cognitive science


. What is minimum number of disks RAID ?
Ans : 3

. One power and one neutral wire is know as
Ans : Single phase

. Which is valid  mode of operation in vi editor ?
Ans :Command mode


. you have created a shell script and wants to run 
the script . what should you do before trying to run the 
script ?
Ans :Update the execute permission of the script…

. To find length of the string
       String a;
      
      Ans : a.lenght();
 class Box{
       …..
}
Class solution {
Box box[]={b1,b2,b3,b4,b5};
For(int i=0;i<box.length();i++)
}

Ans : error  




.Mobile devices connect with GPS and camera of 
our phone… ?

 Ans : True
.Delete lines from ‘this’ file .. ?

Ans : Sed/’this’/d file



.In python section qn is
Print(‘TCS’+8)
Ans : Error
.When tcs was established ?

Ans : 1968
. Object includes ?
Options
  1. attributes
  2.behaviour
  3.both
  4.None
Ans : 2(Object includes behaviour and identity)
Agile principle

Options
  1. Leadership over management      
  2. Management over management
  3. Adaptive over prescriptive      4.Prescriptive over adoptive                       5.Customer colloborative over contrort negotiation                                           6.Contrort negotiation over customer collaborative



Ans : 1,3,5


 

.Tcs values are

Ans: Integrity , Leading change , Respect for 
individual , Excellence , learning and sharing.

.We will be fair ,honest, transparent and ethical in our
 conduct; everything we do must stand the test of public
 scrutiny ? this refers to which value ?

Ans: Integrity

.To increase the size of a column in SQL.. ?

Ans : ALTER TABLE table_name 
MODIFY column_name datatype(new_size)
.In unix section qn is
S=0 {s=s+$2}

Ans : Sum of second column
.Is caption rage used to give table a caption … ?
Ans : True

.Text-align:justify… ?

Options

  1. Left     2 Right          3.Center               4.None of these

Ans : 4
.If a client become informal to you then what will you
 do… ?
//partially same meaning options , not exactly same

Ans : will him to be formal
.One question from plsql  was” the upward to lower flow 
in a loop is …. ?”

Ans : reverse


.If you are in between you assessment and your
 manager told you to attend the call what you will do… ?
//partially same meaning options , not exactly same
Ans : say him politely that you will attend the call
 after your assessment




.Unix command to remove duplicates in line .. ?
Ans : sort –u


.What is output of below commands.. ?

grep –o cat animal.txt
grep ‘cat’ animal.txt


Ans :cat cat


.Question from javascript section ,”var x=100+5**3 ? “

Ans : 225


.File and directory permission access will be done 
by which command … ?
Ans : chmod


.What is purpose of type and rowtype ..?
(from plsql section)

Ans: TYPE provides datatype of a variable and 
ROWTYPE provides record type that represents 
a entire row of a table or view or columns selected
 in the cursor

On update cascade ensures what .. ?

Ans :Data integrity


Flow of information in Rio.. ?

Ans :Primary -> Secondary -> KT