Simple interview questions python (2)

  Wrote earlier about some of the python face interview test questions encountered, some friends say very good message, so quiet and collected a number of interview questions for gold, 3 silver and 4 of next year to prepare for (the quiet and write python face a number of questions and we tested the interview questions)

1. What processes are automated?

First built environment, and build automation framework based on the project, write automation use cases, use cases finishing, automatic generation of test reports, and then integrated into the operating jenkins

2, app crash occurs and how ANR operation?

ANR appears and crash were crawling reproduction log (adb command)

3, the implementation of use cases failure occurred in an automated process, how should we do?

Write automated Use Cases assertions written in clear, then also you can save a screenshot by after the failure of the use cases, help us follow-up to see the failure reason use cases, the automation fails use cases, manual operation to see if there really a problem, and if not, you can Check whether the clerical error codes

4, the web and app, an element clearly targeted to, but invalid clicks

  • web automation, we can click on elements through JS,
  • app automation if it is time to H5 is no way to click on the page, we need to use the touch module webdriver
  • If invalid clicks app automation, we can simulate clicking through coordinates

5, app and web test test What is the difference?

Overall, web app testing and test general there is no distinction requires needs assessment, use case review, mention bug, submit test reports. The only difference is that app tests need to be installed, download, upgrade, and covers the cold and warm starts, as well as telephone, lack of electricity, information, and other software on the handset interoperability testing

6, how to automate screenshots

By function  get_screensho t_as_file (self, filename)  screenshot

7, the current test will need to rely on login, automation, how to operate?

  • If it is, then you can use the interface to the automation session hold a session, then perform the operation after login
  • If it is web automation, then you can locate enter the account password to complete login
  • If the app is automated, then you can locate the account to complete the login password input

8, you have used in data-driven automation do?

The general use of ddt data drive to store data, sometimes using paramunittest

9, two data sets are a = [1,2,3,4,5] b = [ 'a', 'b', 'c', 'd', 'e'], by how to python c = [ 'a1', 'b2', 'c3', 'd4', 'e5']

a=[1,2,3,4,5]
b = ["a", "b", "c", "d", "e"]
c = [str(i)+str(j) for i,j in zip(b, a)]
print(c)


打印结果:
['a1', 'b2', 'c3', 'd4', 'e5']

10, python achieved by 9 by 9 formulas

# 9*9口诀
for i in range(1,10):
    for j in range(1,i+1):
        print("%s*%s=%s"%(i,j,i*j),end=" ")
    print("")

输出结果:
1*1=1 
2*1=2 2*2=4 
3*1=3 3*2=6 3*3=9 
4*1=4 4*2=8 4*3=12 4*4=16 
5*1=5 5*2=10 5*3=15 5*4=20 5*5=25 
6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36 
7*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49 
8*1=8 8*2=16 8*3=24 8*4=32 8*5=40 8*6=48 8*7=56 8*8=64 
9*1=9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81 

11, achieved by python 'hello_world_anjing' becomes [ 'hello', 'world', 'anjing']

= A ' hello_world_anjing ' 
C = a.split ( ' _ ' )
 Print (C) 


# output: 
# [ 'Hello', 'World', 'anjing']

12, a python list by determining the number of positive and negative numbers

a = [1, 3, 5, 7, 0, -1, -9, -4, -5, 8]
b = []
c = []
for i in a:
    if i>0:
        b.append(i)
    elif i < 0:
        c.append(i)
    else:
        pass
print(len(b))
print(len(c))

执行结果:
5
4

13, how to convert a string and a list by python

# String conversion list 
A = ' anjing ' 
C = List (A) 
D = a.split ( '  ' )
 Print (D) 

# list convert a string 
A = [ ' . 1 ' , ' 2 ' , ' . 3 ' , ' . 4 ' ] 
C = ' ' .join (A)
 Print (C)

 14, to re-list

# List deduplication 
A = [ ' . 1 ' , ' 2 ' , ' . 3 ' , ' . 4 ' , ' 2 ' , ' . 1 ' , ' . 4 ' ] 
C = SET (A)
 Print (C) 

# { '2' , '3', '1', '4'}

15, what is represented in python __int__

# Initialization function, used to complete some of the default settings 

class the Test ():
     DEF  __init__ (Self): 
        self.name = ' anjing ' 
        self.age = ' 18 ' 

A = the Test ()
 Print ( ' My name is: S% ' % a.name)
 Print ( ' my age is:% S ' % a.age) 


my name is: anjing 
my age is: 18

16, turned over the list

# List flip 
A = [1,2,3,4,5 ]
 Print (A [:: -. 1 ]) 


# [. 5,. 4,. 3, 2,. 1]

17. What loging module? what's the effect?

loging belong log module, when we write the script tells us every step of doing, if given, then, to help us analyze the data, that is, we usually say RBI's role

import logging

logging.basicConfig(level=logging.DEBUG,
                    format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
                    datefmt='%a, %d %b %Y %H:%M:%S',
                    filename='/tmp/test.log',
                    filemode='w')
logging.debug('debug message') # 低级别的,调试信息
logging.info('the Message info ' ) # normal information 
logging.warning ( ' warning the Message ' ) # warning information 
logging.error ( ' error the Message ' ) # error message 
logging.critical ( ' Critical the Message ' ) # high-level critical error message #

18 difference, append and extend the

# append
a = [1,2,3,4,5]
c = [6,7]
a.append(c)
print(a)

# [1, 2, 3, 4, 5, [6, 7]]

# extend

a = [1,2,3,4,5]
c = [6,7]
a.extend(c)
print(a)

# [1, 2, 3, 4, 5, 6, 7]

19, by zip codes introduce function usage

zip () function when the operation will be one or more sequences as an argument and returns a list of tuples, oral zip () accepts any type of parameter sequence, also supports a plurality of parameters through.

# 列表
a = [1,2]
b = [3,4]
c = [i for i in zip(a,b)]
print(c)

# [(1, 3), (2, 4)]

# 元祖
a = (1,2)
b= (3,4)
c = [i for i in zip(a,b)]
print(c)

# [(1, 3), (2, 4)]

# 字符串
a = '12'
b = '34'
c = [i for i in zip(a,b)]
print(c)

# [(1, 3), (2, 4)]

20, if a 3-digit numbers equal to the cube and you said to this number is the number of daffodils. Seek within a few daffodils 1000 (3 digits)

sxh = []
for i in range(100, 1000):
    s = 0
    m = list(str(i))
    for j in m:
        s += int(j)**len(m)
        if i == s:
            sxh.append(i)
print("100-999的水仙花数:%s" % sxh)

# 100-999的水仙花数:[153, 370, 370, 371, 407]

Guess you like

Origin www.cnblogs.com/qican/p/12144942.html