n = -1 count1 = 0 count2 = 0 s = 0 while n != 0: n = int(input("Enter an integer,the input ends if i is 0:")) if n > 0: count1 += 1 elif n == 0: print("You did not enter any number") else: count2 += 1 s += n m = s / (count1 + count2) print(f"The number of positives is {count1}") print(f"The number of negatives is {count2}") print(f"The total is {s}") print(f"The average is {m}")
print('{:^8s}'.format("公斤"), end="") print('{:^8s}'.format("磅"), end="") print('{:^8s}'.format("磅"), end="") print('{:^8s}'.format("公斤")) for i in range(1, 200, 2): b = i * 2.2 print('{:^8d}'.format(i), end="") print('{:^8.1f}'.format(b), end="") a = (17.5+i*2.5) / 2.2 print('{:^8.2f}'.format(a), end="") print('{:^8.0f}'.format(17.5+i*2.5), end="") print()
n = eval(input()) for i in range(2,n): while n % i == 0: print(i, end=" ") n = n / i
for i in range(1, 7): j = 1 while j <= i: print(j, end=" ") j += 1 print() print() for i in range(1, 7): j = 1 while j <= 7 - i: print(j, end=" ") j += 1 print() print() for i in range(1, 7): j = 1 while j <= 6 - i: print(" ", end=" ") j += 1 while i > 0: print(i, end=" ") i -= 1 print() print() for i in range(1, 7): j = 1 while j < i: print(' ', end=" ") j += 1 j = 1 while j <= 7 - i: print(j, end=" ") j += 1 print()