while True:

プログラミング演習(備瀬 竜馬)

第4回

小問番号はコメント(#)を参照
# 4_A_1
mylist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
print(mylist[1:-2])


# 4_A_2
char = input()
chars = char.split()
print(chars)
print("単語数:{}".format(len(chars)))


# 4_A_3
nums = [5, 5, 4, 3, 1, 7, 2]
print("最大値:{}".format(max(nums)))
print("最小値:{}".format(min(nums)))
print("平均値:{}".format(sum(nums) / len(nums)))


# 4_B_1
number = input("Enter numbers with 「,」")
numbers = number.split(",")
nums = [float(x) for x in numbers]
print("最大値:{}".format(max(nums)))
print("最小値:{}".format(min(nums)))
print("総和:{}".format(sum(nums)))
print("平均:{}".format(sum(nums) / len(nums)))


# 4_C_1
english = ["", "January", "February", "March", "April"
, "May", "June", "July", "August", "September", "
October", "November", "December"]
month = input()
month = int(month)
print("{}月の英語は{}です".format(month, english[month]))


# 4_C_2
days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
month0 = input("Month?")
day0 = input("Day?")
month = int(month0)
day = int(day0)
count = sum(days[0:month - 1])
print("1月1日から{}日経過しています".format(count+day))
  
ページのトップへ戻る