Lesson4 單元的題目偏向簡單
主要都是在考你知不知道起始值跟結束值會不會設定
(⭐ 代表加碼題目)
a = int(input())
for i in range (a):
print(i+1)
a = int(input())
b = int(input())
for i in range (a, b+1):
print(i)
a = int(input())
for i in range (1, a+1, 2):
print(i)
a = int(input())
b = int(input())
if a>b:
for i in range (a, b-1, -1):
print(i)
else:
for i in range (a, b+1, 1):
print(i)
a = int(input())
for i in range (a, -1, -1):
if i%2==0:
print(i)
sum = 0
for i in range(10):
sum += int(input())
print(sum)
a = int(input())
sum = 0
for i in range(a):
sum += int(input())
print(sum)
a = int(input())
sum = 1
for i in range(a):
sum *= int(input())
print(sum)
a = int(input())
sum = 0
for i in range (0, a+1, 1):
sum += i**3
print(sum)
a = int(input())
ans = 1
for i in range (1, a+1):
ans *= i
print(ans)
a = int(input())
sum = 0
for i in range (a):
if int(input()) == 0:
sum += 1
print(sum)
a = int(input())
sum = 0
for i in range (1, a+1):
temp = 1
for j in range (1, i+1):
temp *= j
sum += temp
print(sum)
a = int(input())
b = int(input())
for i in range (a, b+1):
print('{}*{}={}'.format(i, i, i*i))
a = int(input())
for i in range(1, a+1):
for j in range (1, i+1):
print(j, sep='', end="")
print("")
n = int(input())
answer = 'PRIME'
for i in range(2, n - 1):
if n % i == 0:
answer = 'COMPOSITE'
print(answer)
a = int(input())
b = int(input())
for i in range(a, b+1):
for j in range (2, i):
if (i%j)==0:
break
else:
print(i)
a = int(input())
b = int(input())
sum = 0
for i in range(a, b+1):
for j in range (2, i):
if (i%j)==0:
break
else:
sum += 1
print(sum)
a = int(input())
sum = 0
total = int((1+a)*a/2)
for i in range (1, a):
sum += int(input())
print(total-sum)