欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

homework03

程序员文章站 2022-06-10 16:12:54
...

homework03

x = 1
zs = 0
fs = 0
i = 0
sum_ = 0

while x != 0:
    x = int(input('输入一个整数,以输入0结束'))
    if(x>0):
        zs += 1
    elif(x<0):
        fs += 1
    i += 1
    sum_ = sum_ + x
if sum_ != 0:
    xx = sum_/(i-1)
    print(zs,fs,sum_,xx)  
else:
    print("结束") 

homework03
homework03

a = 10000
for i in range(14):
    a = a*0.05+a
    if i == 11:
        print(a)

homework03
homework03

 count=0
    for i in range(100,1001):
        if i%5 == 0 and i%6 == 0:
            count += 1
            print(i,end=" ")
            if count % 10 == 0:
                print("\n")

homework03
homework03

n = 1
while n*n <= 12000:
    n += 1
print(n)

n1 = 1
while n1**3 <= 12000:
    n1 += 1
print(n1)

homework03
homework03

 n = 0
    for i in range(1,5000,-1):
        n= n + 1/i
    print(n)
    
    n = 0
    for i in range(1,5000,1):
        n= n + 1/i
    print(n)

homework03
homework03

sum = 0
for i in range(3,100,2):
    sum += (i-2)/i
print(sum)

homework03

homework03

x = 0
for i in range(1,10000):
    x += 4*((-1)**(i+1)/(2*i-1))
    print(x)

homework03
homework03

   for i in range(1,10001):
    s= 0
    for j in range(1,i):
        if i%j == 0:
            s = s+j
    if i == s:
        print(i)

homework03
homework03

       a = [ ] 
for i in range(1,8):
    for j in range(1,8):
        if i != j and sorted([i,j]) not in a:
            a.append([i,j])
print(a)
print(len(a))

homework03
homework03

import numpy as np
arr = []
i = 1
while i <= 10:
    x = float(input('请输入十个数'))
    arr.append(x)
    i += 1
arr_mean = np.mean(arr)
arr_var = np.var(arr)
print(arr_mean)
print(arr_var)

homework03

推荐阅读