面试问题
1、自我介绍
2、做功能测试和自动化测试的占比 10
3、python基础 如何对列表进行去重处理。考察数据类型 set(list1)
list1 = [1, 2, 6,3,5,5,8,8,9]
print(set(list1))
4、python基础 Python中常用的数据类型有哪些
数字、布尔值、字符串、元组、列表、字典、集合
Numbers、Boolean、string、tuple、list、dictionaties、set
5、一个文本有大小写,获取大小写的数量。考察字符串操作
string1 = "abcvDdefaG"
num1 = 0
num2 = 0
# num1 大写数量 num2 小写数量
# 方法一:使用内置函数
for ele in string1:
if ele.isupper():
num1 += 1
elif ele.islower():
num2 += 1
print("大写字母有%d个,小写字母有%d个" % (num1, num2))
# 方法二:使用ASCII码值来判断字母大小写
# for letter in string1:
# if ord(letter) >= 65 and ord(letter) <= 90:
# num1 += 1
# elif ord(letter) >= 97 and ord(letter) <= 122:
# num2 += 1
# print("大写字母有%d个,小写字母有%d个" % (num1, num2))
# 方法三:使用python中的字母表
# 定义字母表
# uppercase_letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
# lowercase_letters = "abcdefghijklmnopqrstuvwxyz"
# for ele in string1:
# if ele in uppercase_letters:
# num1 += 1
# elif ele in lowercase_letters:
# num2 += 1
# print("大写字母有%d个,小写字母有%d个" % (num1, num2))
# 方法四:使用正则表达式
# 导入re模块
# import re
# for letter in string1:
# if re.match(r'[A-Z]', letter):
# num1 += 1
# elif re.match(r'[a-z]', letter):
# num2 += 1
# print("大写字母有%d个,小写字母有%d个" % (num1, num2))
6、字符串切割的关键字 split
7、获取字典中所有的key和value值
# 获取字典的key和value值
dict = {"a": 1, "b": 2}
# for key, v in dict.items():
# print("key={}".format(key))
# print("v={}".format(v))
# for item in dict.items():
# key = item[0]
# value = item[1]
# print(key, value)
for key in dict.keys():
print(key)
for value in dict.values():
print(value)
8、对Python递归算法怎么看
9、计算1-100偶数之和
sumEven = 0
for n in range(0, 101, 2):
print(n)
sumEven += n
print(sumEven)
10、Sql 订单明细表orders,按各个月份month和各个车型carType的订单数目
Select count() from orders group by month,cartype
Select cartype, sum(month) from orders group by month,cartype;
Select carType,
Sum(month(orderDate)=1 and year(orderDate)= 2023) as jan2023,
Sum(month(orderDate)=2 and year(orderDate)=2023) as feb2023,
Sum(month(orderDate)=3 and year(orderDate)=2023) as mar2023,
Sum(month(orderDate)=4 and year(orderDate)=2023) as apr2023,
Sum(month(orderDate)=5 and year(orderDate)=2023) as may2023,
Sum(month(orderDate)=6 and year(orderDate)=2023) as jun2023
From orders
Group by cartype
11、车型A的订单表ordersA 车型B的订单表ordersB,有销售人员,查询既卖了车型A又卖了车型B的所有销售人员salesperson的名字,并按他们卖的车总数进行降序排序
Select salesperson,count() from (select * from ordersA A left join on orderB B where A.salesperson = B.salesperson) order by count(*) desc;