Friday, November 18, 2022

Technical Info

 

Windows Subsystem for Linux Has Reached v1.0 Stable Release


Windows Subsystem for Linux (WSL) is a tool that lets you run a GNU/Linux environment inside a Windows system without needing a virtual machine or dual-boot.

https://news.itsfoss.com/wsl-stable-available/


Saturday, October 15, 2022

Pytorch framework & Tensorflow Framework

Pytorch and Tensorflow are the two most popular deep-learning frameworks. 


Pytorch was developed by Facebook and released to the public in 2016.

Pytorch is a low-level API for NLP(natural language processing) and computer vision. it is a more powerful version of Numpy.



TensorFlow was developed by Google and released to the public in 2015. Production and research are the main uses of TensorFlow.




Friday, July 15, 2022

AI ML DL

 




JenkinsThe leading open source automation server, Jenkins provides hundreds of plugins to support building, deploying, and automating any project.



Difference between Private Key and Public Key


KeyPrivate KeyPublic Key
AlgorithmPrivate key is used for both encrypting and decrypting the sensitive data. It is shared between the sender and receiver of encrypted data.Public key is used only for the purpose of encrypting the data.
PerformanceThe private key mechanism is faster.The public key mechanism is slower.
SecrecyThe private key is kept secret and not public to anyone apart from the sender and the receiver.The public key is free to use and the private key is kept secret only.
TypeThe private key mechanism is called "symmetric" because a single key is shared between two parties.The public key mechanism is called "asymmetric" because there are two keys for different purposes.
SharingThe private key is to be shared between two parties.The public key can be used by anyone but the private key is to be shared between two parties only.
TargetsPerformance testing checks the reliability, scalability, and speed of the system.

Thursday, April 7, 2022

Python if-else Interview questions

What are the three main conditional statements in Python?
Answer       if, elif, and else


. What will be the output of the following Python code?

names_1 = ["Narendra", "Boyina", "raj", "Mahalakshmi"]

if  'Raj' in names_1:

print(1)

else:

print(2)

a) None

b) 1

c) 2

d) Error


Answer: c

Explanation: Python is case sensitive, "if" condition failed because "Raj" is not available in that list, "raj" is available, so else block statement is executed.

========================================================================

A company decided to give a bonus of 5% to the employee if his/her year of service is more than 5 years.
Ask users for their salary and year of service and print the net bonus amount.

Answer:


salary = int(input("Enter salary"))

yos = int(input("Enter year of service"))

if yos>5:

  print "Bonus is",.05*salary

else:

  print "No bonus"

========================================================================

 Accept the kilometers covered  for the rented car and calculate the bill according to the following criteria:

First 10 Km              Rs11/km

Next 90Km               Rs 10/km

After that               Rs9/km

Answer
.

kmc = int(input("Enter the kilometer covered"))

if kmc <=10 :

    amt = kmc * 11

elif kmc > 10 and kmc <= 100:

    amt = 110 + (kmc - 10)*10

elif kmc > 100:

    amt = 1010 + (kmc - 100)*9

print("Total amount to pay is ", amt)

========================================================================



========================================================================

Write a program to calculate the electricity bill (accept the number of units from user) according to the following criteria :

             Unit                                                     Price  

First 100 units                                               no charge

Next 100 units                                              Rs 5 per unit

After 200 units                                             Rs 10 per unit

(For example, if the input unit is 350 then the total bill amount is Rs2000)


logic.

amt=0

numer_units=int(input("Enter number of electric unit"))

if numer_units<=100:

     amt=0

if numer_units>100 and numer_units<=200:

     amt=(numer_units-100)*5

if numer_units>200:

     amt=500+(numer_units-200)*10

print("Amount to pay :",amt)

========================================================================

Accept any city from the user and display a monument of that city.

  City                                 Monument

  Delhi                               Red Fort

  Agra                                Taj Mahal

  Jaipur                              Jal Mahal


 Answer

 

city = input("Enter name of the city")

if city.lower()=="delhi":

    print("Monument name is : Red Fort")

elif city.lower()=="agra":

    print("Monument name is : Taj Mahal")

elif city.lower()=="jaipur":

    print("Monument name is : Jal Mahal")

else:

print("Enter correct name of city")


========================================================================

Write a program to find the largest number out of three, excepted by the user.

 Answer


num1 = int(input("Enter first number"))
num2 = int(input("Enter second number"))
num3 = int(input("Enter third number"))
if num1 > num2 and num1 > num3:
      print("Greatest number is ", num1)
if num2 > num1 and num2 > num3:
      print("Greatest number is ", num2)
if num3 > num2 and num3 > num1:
     print("Greatest number is ", num3)
print("Enter correct name of city")

========================================================================

Accept the following from the user and calculate the percentage of class attended:

a.     Total number of working days

b.     Total number of absent days 

After calculating the percentage show that, If the percentage is less than 75 then the student will not be able to sit in the exam.

 Answer

 

nd = int(input("Enter total number of working days"))

na = int(input("Enter number of days  absent"))

per=(nd-na)/nd*100

print("Your attendance is ",per)

if per <75 :

     print("You are not eligible for exams")

else:

     print("You are eligible for writing exam")

========================================================================


                                Request: Please provide your valuable comments

Python Comprehensions Interview questions - Multiple choice

 1. Suppose list1 = [0.5 * x for x in range(0, 4)], list1 is:

a) [0, 1, 2, 3]

b) [0, 1, 2, 3, 4]

c) [0.0, 0.5, 1.0, 1.5]

d) [0.0, 0.5, 1.0, 1.5, 2.0]


Answer: c

Explanation: Execute in the shell to verify.


2. What will be the output of the following Python code?

names_1 = ["Narendra", "Bhagyasree", "Raj", "Mahalakshmi"]

names_2 = [name.lower() for name in names_1]

 print(names_2[2][0])

a) None

b) R

c) r

d) b


Answer: c

Explanation: List Comprehension is a shorthand for creating new lists.


3. What will be the output of the following Python code?

>>>m = [[x, x + 1, x + 2] for x in range(0, 3)]

a) [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

b) [[0, 1, 2], [1, 2, 3], [2, 3, 4]]

c) [1, 2, 3, 4, 5, 6, 7, 8, 9]

d) [0, 1, 2, 1, 2, 3, 2, 3, 4]


Answer: b

Explanation: Execute in the shell to verify.


4. How many elements are in m?

m = [[x, y] for x in range(0, 4) for y in range(0, 4)]

a) 8

b) 12

c) 16

d) 32


Answer: c

Explanation: Execute in the shell to verify.

 

5. What will be the output of the following Python code?

a=[1,2,3,4]

b=[sum(a[0:x+1]) for x in range(0,len(a))]

print(b)

a) 10

b) [1,3,5,7] 

c) 4

d) [1,3,6,10]


Answer: d

Explanation: The above code returns the cumulative sum of elements in a list


6. What will be the output of the following Python code?

>>>t = (1, 2, 4, 3, 8, 9)

>>>[t[i] for i in range(0, len(t), 2)]

a) Error

b) [1, 2, 4, 3, 8, 9]

c) [1, 4, 8]

d) (1, 4, 8)


Answer: c

Explanation: Execute in the shell to verify.


7. What will be the output of the following Python code?

a={i: i*i for i in range(6)}

print(a)

a) Dictionary comprehension doesn’t exist

b) {0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6:36}

c) {0: 0, 1: 1, 4: 4, 9: 9, 16: 16, 25: 25}

d) {0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25}


Answer: d

Explanation: Dictionary comprehension is implemented in the above piece of code.


8. What will be the output of the following Python code?

 a={i: 'A' + str(i) for i in range(5)}

print(a)  

a) An exception is thrown

b) {0: ‘A0’, 1: ‘A1’, 2: ‘A2’, 3: ‘A3’, 4: ‘A4’}

c) {0: ‘A’, 1: ‘A’, 2: ‘A’, 3: ‘A’, 4: ‘A’}

d) {0: ‘0’, 1: ‘1’, 2: ‘2’, 3: ‘3’, 4: ‘4’}


Answer: b 

Explanation: Dictionary comprehension and string concatenation is implemented in the above piece of code.


 What will be the output of the following Python code?

a="hello"

b=list( (x.upper(), len(x))  for x in a)

print(b)

a) [(‘H’, 1), (‘E’, 1), (‘L’, 1), (‘L’, 1), (‘O’, 1)]

b) [(‘HELLO’, 5)]

c) [(‘H’, 5), (‘E’, 5), (‘L’, 5), (‘L’, 5), (‘O’, 5)]

d) Syntax error


Answer: a

Explanation: Variable x iterates over each letter in the string hence the length of each letter is 1.


Python Functions Interview questions

1. What will be the output of the following Python code?

myList = [1, 2, 3, 4, 5, 6]

for i in range(1, 6):

myList[i - 1] = myList[i]

for i in range(0, 6): 

print(myList[i], end = " ")

a) 2 3 4 5 6 1

b) 6 1 2 3 4 5

c) 2 3 4 5 6 6

d) 1 1 2 3 4 5


Answer: c

Explanation: Execute in the shell to verify.


2. What will be the output of the following Python code?

def narendra(values):

values[0] = 44


v = [1, 2, 3]

narendra(v)

print(v)

a) [1, 44]

b) [1, 2, 3, 44]

c) [44, 2, 3]

d) [1, 2, 3]


Answer: c

Explanation: Execute in the shell to verify.


3. What will be the output of the following Python code?

def narendra(i, values = []):

values.append(i)

return values

 

narendra(1)

narendra(2)

v = narendra(3)

print(v)

a) [1] [2] [3]

b) [1] [1, 2] [1, 2, 3]

c) [1, 2, 3]

d) 1 2 3


Answer: c

Explanation: Execute in the shell to verify


4. What will be the output of the following Python code?

def addItem(listParam):

listParam += [1]

 

mylist = [1, 2, 3, 4]

addItem(mylist)

print(len(mylist))

a) 1

b) 4

c) 5

d) 8


Answer: c

Explanation: + will append the element to the list.


5. What will be the output of the following Python code?

def increment_items(L, increment):

i = 0

while i < len(L):

L[i] = L[i] + increment

i = i + 1

 

values = [1, 2, 3]

print(increment_items(values, 2))

print(values)

a)    None

           [3, 4, 5]

b)    None

           [1, 2, 3]

c)    [3, 4, 5]

           [1, 2, 3]

d)    [3, 4, 5]

           None


Answer: a

Explanation: increment_items() function does not have a return keyword, so by default if any function does not have a return keyword, then that function will return None


6. What will be the output of the following Python code?

def example(L):

i = 0

result = []

while i < len(L):

result.append(L[i])

i = i + 3

return result

a) Return a list containing every third item from L starting at index 0

b) Return an empty list

c) Return a list containing every third index from L starting at index 0

d) Return a list containing the items from L starting from index 0, omitting every third item


Answer: a

Explanation: Run the code to get a better understanding of many arguments.


7. What will be the output of the following Python code?

     def maha(list):
            v = list[0]
        for e in list: # iterate inner list
        if v < e:
        v = e
        return v

        values = [[3, 4, 5, 1], [33, 6, 1, 2]]
        for row in values:
        print(maha(row), end=" ")
         a) 3 33

        b) 1 1

        c) 5 6

        d) 5 33


Answer: d

Explanation: Execute in the shell to verify.


8. What will be the output of the following Python code?

    def maha(m):
    v = m[0][0]
for row in m:
for element in row:
if v < element:
v = element
print(v)

    maha(data[0])

        a) 1

b) 2

c) 4

d) 5


Answer: c

Explanation: Execute in the shell to verify.


9.  What will be the output of the following Python code?

def unpack(a,b,c,d):

print(a+d)

x = [1,2,3,4]

unpack(*x)

a) Error

b) [1,4]

c) [5]

d) 5


Answer: d

Explanation: unpack(*x) unpacks the list into the separate variables. Now, a=1 and d=4. Thus 5 gets printed.


10. What will be the output of the following Python code?

def change(var, lst):

var = 1

lst[0] = 44

k = 3

a = [1, 2, 3]

change(k, a)

print(k)

print(a)


a) 3

[44, 2, 3]

b) 1

[1,2,3]

c) 3

[1,2,3]

d) 1

[44,2,3]


Answer: a

Explanation: A list is mutable, hence its value changes after the function call. However, the integer isn’t mutable. Thus its value doesn’t change


11. What will be the output of the following Python code snippet?

total={}

def insert(items):

if items in total:

total[items] += 1

else:

total[items] = 1

insert('Apple')

insert('Ball')

insert('Apple')

print (len(total))

a) 3

b) 1

c) 2

d) 0


Answer: c

Explanation: The insert() function counts the number of occurrences of the item being inserted into the dictionary. 

There are only 2 keys present since the key ‘Apple’ is repeated. Thus, the length of the dictionary is 2.


12. What will be the output of the following Python code?

a = [5,5,6,7,7,7]

b = set(a)

def test(lst):

if lst in b:

return 1

else:

return 0

for i in  filter(test, a):

print(i,end=" ")

a) 5 5 6

b) 5 6 7

c) 5 5 6 7 7 7

d) 5 6 7 7 7


Answer: c

Explanation: The filter function will return all the values from the list a which are true when passed to the function test.


Request: If you find this information useful, please provide your valuable comments.

Thursday, March 31, 2022

My own logics Development for different requirements. Please Don't open it

=================================================================

write the logic for Image flashing:

import subprocess , time


def is_gki_image_flashed(devi_id):

uname = run_adb_command("adb shell uname -r")

print uname[0], len(uname[0])

length = len(uname[0])

if str == type(uname[0]):

if length>18:

return True

else:

return False



def  gki_image_flashing(device_id,local_image_path,Remote_image_path,image_file_name,otp_file_name=None):

"""

this function will perform GKI image flashing with OTP & without OTP

"""

#shutil.copyfile(Remote_image_path, local_image_path)

if otp_file_name == None:

run_adb_command("adb -s "+device_id+" reboot bootloader")

time.sleep(10)

print("device went to fastboot mode")

outcome = subprocesscheck_output(["fastboot", "devices"])

if device_id in outcome:

run_adb_command("fastboot oem allow_unlock")

run_adb_command("fastboot oem unlock_all")

Image_file = local_image_path+"\\"+image_file_name

cmd = "fastboot flash boot "+Image_file

print(cmd, "command to be executed")

run_adb_command(cmd)

run_adb_command("fastboot -s "+device_id+" erase userdata")

time.sleep(60)

run_adb_command("fastboot -s "+device_id+" reboot")

time.sleep(90)

if check_adb_connection_status(device_id):

Flash_status = is_gki_image_flashed(device_id)

if Flash_status == True:

log_message("GKI Image is flashed on", device_id)

else:

log_message("GKI Image is not flashed on", device_id)

else:

run_adb_command("adb -s "+device_id+" reboot bootloader")

time.sleep(10)

print("device went to fastboot mode")

outcome = subprocess.check_output(["fastboot", "devices"])

if device_id in outcome:

run_adb_command("fastboot oem allow_unlock")

run_adb_command("fastboot flash otp "+otp_file_name)  # Need to provide otp file name along with path

run_adb_command("fastboot oem unlock_all")

Image_file = local_image_path+"\\"+image_file_name

cmd = "fastboot flash boot "+Image_file

run_adb_command(cmd)

run_adb_command("fastboot -s "+device_id+" erase userdata")

time.sleep(60)

run_adb_command("fastboot -s "+device_id+" reboot")

time.sleep(90)

if check_adb_connection_status(device_id):

Flash_status = is_gki_image_flashed(device_id)

if Flash_status == True:

log_message("GKI Image is flashed on", device_id)

else:

log_message("GKI Image is not flashed on", device_id) 

=================================================================


Wednesday, March 2, 2022

General Device/other issues we are facing in real time - How to overcome with solution

Device side issues: 

In the command prompt, if you type "adb devices -l" command then some of the devices may be displayed as unauthorized

List of devices attached

213495xxxxxx0092         unauthorized

solution:  In mobile go to settings then enable user debugging mode properly then try the command.

adb devices -l

List of devices attached

21349xxxxxxx092         device product: Product_Name model: model name device: device_name

======================================================================

Memory-related issues in machines:

Most of the time when we are running automation scripts we will get error messages like:"no space left on device"

solution:   We have to clean up the memory (by deleting dockers, containers, and temporary files) and also used below command 

docker system prune -a   ==> It will clear space on your device by doing the following tasks 

     This command will remove: 

            - all stopped containers

            - all networks not used by at least one container

            - all images without at least one container associated with them

            - all build cache


Note: Every time, before running long-run automation scripts, make sure that machine memory will be sufficient or not? 

======================================================================