#!/usr/bin/python
#coding:utf-8
#while
#计算1+2+3+...+100的和
#计算1+3+5...+99的和
sum=0
i=0
while i<=99:
i=i+1
if i%2==0:
continue
sum=sum+i
print s

#计算2+4+6...+100的和
sum=0
i=0
while i<=99:
i=i+1
if i%2!=0:
continue
s=sum+i
print s

用python脚本来计算100以内奇数或者偶数之和_第1张图片

#!/usr/bin/python
#coding:utf-8
import subprocess
def myping(x):
tmp=subprocess.call('ping -c3 -i0.2 -w2 %s &>/dev/null'%x,shell='True')
if tmp==0:
print '%s is up'%x
else:
print '%s is down'%x
myping('192.168.4.5')
myping('192.168.4.8')
myping('192.168.7.5')