已采纳回答 / 慕斯卡4014295
sum = 0x = 1 #通过x的这个初始值来判,初始值为1,就是奇数,每次都+2肯定所有的都是奇数咯while x < 100: sum += x x += 2print sum
2019-02-22
已采纳回答 / 慕运维4097268
len(L)+1要分开看,len(L)是先求出L的长度,+1是在求出L的长度后加上1。比如len(L)求得L的长度是3,则len(L)+1的结果是4
2019-02-22
最赞回答 / 慕仰5198086
个位是可以是0的呀,因为是三位数,所以百位不能为零,虽然是要找百位和个位相同的数,可以忽略个位是0的数,但是个位是0的数是可以存在的,不影响结果
2019-02-22
import math
def quadratic_equation(a, b, c):
sqrt_num = b ** 2 - 4 * a * c
x1 = (-b + math.sqrt(sqrt_num)) / (2 * a)
x2 = (-b - math.sqrt(sqrt_num)) / (2 * a)
return x1, x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
def quadratic_equation(a, b, c):
sqrt_num = b ** 2 - 4 * a * c
x1 = (-b + math.sqrt(sqrt_num)) / (2 * a)
x2 = (-b - math.sqrt(sqrt_num)) / (2 * a)
return x1, x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
2019-02-22
#coding=utf:8
def square_of_sum(L):
sum_list = 0
for i in L:
x = i ** 2
sum_list += x
return sum_list
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
def square_of_sum(L):
sum_list = 0
for i in L:
x = i ** 2
sum_list += x
return sum_list
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2019-02-22
已采纳回答 / weixin_慕仔4492420
首先执行了if age >= 6: print 'teenager'满足条件时则不再往下执行正确应该这样
age = 8 if age >= 18: print 'adult' elif age >=16 : print '年轻人' else: print 'kid'
2019-02-21
L = []
x = 1
while x <= 100:
L.append(x**2)
x += 1
print sum(L)
x = 1
while x <= 100:
L.append(x**2)
x += 1
print sum(L)
2019-02-21
def area_of_circle(x):
x = 2
s = 3.14*x**2
print(s)
if __name__ == '__area_of_circle__':
area_of_circle()
x = 2
s = 3.14*x**2
print(s)
if __name__ == '__area_of_circle__':
area_of_circle()
2019-02-21
s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for x in L:
if x in s:
s.remove(x)
else:
s.add(x)
print s
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for x in L:
if x in s:
s.remove(x)
else:
s.add(x)
print s
2019-02-21