python面试题
面试题:
逻辑运算符:
print(1 > 2 or 3 and 4 < 6)
print(2 or 3 and 4 < 6)
python2x 与 python3x 的区别
#匿名函数 #1.求结果 v = [lambda :x for x in range(10)] print(v) print(v[0]) print(v[0]()) #2.求结果 v = (lambda :x for x in range(10)) print(v) print(v[0]) print(v[0]()) print(next(v)) print(next(v)())
# 面向对象特性之继承--面试题 class Foo: def __init__(self): self.func() def func(self): print('in Foo') class Son(Foo): def func(self): print('in Son') s1 = Son() ################## class Foo: Country = 'China' def func(self): print(self.Country) class Son(Foo): Country = 'English' def func(self): # 走这个方法 print(self.Country) s = Son() s.func() #################### class Foo: Country = 'China' def func(self): # 走这个方法 print(self.Country) class Son(Foo): Country = 'English' s = Son() s.func() # English ######################### class Foo: Country = 'China' def func(self): print(self.Country) class Son(Foo):pass s = Son() s.func() # 'China'
#python中...等于pass s = ['a','b','c'] for i in s: if i == 'a': ... else: print(i)
#数学的算法---》牛顿偏离法 sum = 1.2 - 1.0 if sum == 0.2: while True: print('1') else: print('2')

浙公网安备 33010602011771号