for seireki in range(1989, 2017):
print("Year" + str(seireki) + "Year", end="")
heisei = seireki - 1988
print("Heisei" + str(heisei) + "It's the year.")
<output>
The year 1989 is Heisei 1.
The year 1990 is 1990.
It is 1991, 1991.
It is 1992 and 1992 in the Christian era.
....
nums = [1, 3, 5, 6, 3, 2, 5, 23, 2]
# print(nums)
sum = 0
for i in nums:
# print(i)
sum += (i)
# print(sum)
print(sum)
>>50
import random
hp = 20
while hp > 0:
hit = random.randint(1, 10)
print("To slime" + str(hit) + "Damaged!")
hp -= hit
print("The remaining HP" + str(hp) + "is!")
print("Defeated slime")
<Output value>
Inflicted 1 damage on slime!
The remaining HP is 19!
Inflicted 9 damage on slime!
The remaining HP is 10!
Inflicted 5 damage on slime!
The remaining HP is 5!
Inflicted 3 damage on slime!
The remaining HP is 2!
Inflicted 2 damage on slime!
The remaining HP is 0!
Defeated slime
Recommended Posts