Python面试攻略(嗨谈篇) 2018-04-13 DataCastle DataCastle数据城堡
写在前面
千呼万唤始出来,咱们需要的面试文档终于整理出来啦!这一次,DC君为大家送上的python面试题之基础概念篇。通过对十几份面试题目的整理,DC君选出了其中出现频率最高的十个题目,附上答案供各位小伙伴参考!
import random | |
def partation(ints, low, high): | |
pivot = ints[random.choice(range(low, high + 1))] | |
while low <= high: | |
while ints[low] < pivot: | |
low += 1 | |
while pivot < ints[high]: | |
high -= 1 |
Python面试攻略(嗨谈篇) 2018-04-13 DataCastle DataCastle数据城堡
写在前面
千呼万唤始出来,咱们需要的面试文档终于整理出来啦!这一次,DC君为大家送上的python面试题之基础概念篇。通过对十几份面试题目的整理,DC君选出了其中出现频率最高的十个题目,附上答案供各位小伙伴参考!
import random | |
def insert_sort(ints): | |
n = len(ints) | |
for i in range(1, n): | |
if ints[i] >= ints[i - 1]: | |
continue | |
tmp = ints[i] | |
while i > 0 and tmp < ints[i - 1]: |
import random | |
def select_sort(ints): | |
n = len(ints) | |
for i in range(0, n - 1): | |
minPos = i | |
for j in range(i + 1, n): | |
if ints[j] < ints[minPos]: | |
minPos = j |
import random | |
def bubble_sort(ints): | |
n = len(ints) | |
for j in range(0, n - 1): | |
flag = False | |
for i in range(0, n - 1 - j): | |
if ints[i] > ints[i + 1]: | |
flag = True |
import re | |
import sys | |
from collections import Counter | |
def read(path): | |
pat = re.compile(r'\s+') | |
with open(path, encoding='utf-8') as f: | |
for line in f: | |
for word in pat.split(line.rstrip()): | |
re_word = word.strip(r'\"').strip(r"\'") |
""" | |
ENV: Python3, pandas pip3 install pands or pip install pandas | |
""" | |
import pandas as pd | |
import sys | |
import os | |
from datetime import datetime | |
class Node: | |
__slots__ = ('val', 'next') | |
def __init__(self, val): | |
self.val = val | |
self.next = None | |
def reverse(head): | |
if head: |
import sys | |
import re | |
import os | |
import subprocess | |
CMD = r'\\ccpsofsep\am_s2\users\kskumar\Tools\sox\sox.exe {0} -e ms-adpcm {1}' | |
def read(path): | |
pat = re.compile(r'\s+') |