モナーのパイソンでゴーゴー

湘南あたりの海辺より

2020-03-01から1ヶ月間の記事一覧

(*´ω`) 東京感染者最多60名以上

実行結果 ソース # 該当年齢を出す ages = [28, 50, 8, 20, 78, 25, 22, 10, 27, 33] num = 5 samples = list() for data in ages: if 20 <= data < 30: samples.append(data) if len(samples) == num: break print(samples) print(' ∧ ∧ 感染爆発の重大局面…

(*´ω`)夕べはうまくいかなかったのになあ今日はあっという間にできた 

実行結果 ソース # 平均点を求める count = 0 student_num = int(input('学生の数を入力してください>>')) score_list = list() while count < student_num: count += 1 score = int(input('{}人目の試験の得点を入力>>'.format(count))) score_list.append(…

(*´ω`)ひつじが・・・ムニャムニャ

実行結果 ソース is_awake = True count = 0 while is_awake == True: count += 1 print('ひつじが{}匹'.format(count)) key = input('もう眠りそうですか?(y/n)>>') if key == 'y': is_awake = False print('z...z...z....') print(' ∧ ∧ good job!')print…

(*´ω`)羊が3匹で寝てしまいました

実行結果 ソース count = 0 while count < 3: count += 1 print('ひつじが{}匹'.format(count)) print('z...z...z....') print(' ∧ ∧ good job!')print('( ゚Д゚)')print('海と猫が好き')

(*´ω`)マッタリしようよ

実行結果 ソース #トマトジュースも好きですよ name = input('あなたの名前を入力してください>>') print('{}さん、こんにちは'.format(name)) if name == 'モナー': print('モナーさんに会えて嬉しいです') food = input('{}さんの好きな食べ物を教えてくだ…

(*´ω`)60点以上100点未満は合格

実行結果 ソース score = int(input('試験の点数を入力>>')) if score >= 60 and score <= 100: print('合格') else: print('不合格') print(' ∧ ∧ good job!')print('( ゚Д゚)')print('海と猫が好き')

(*´ω`) スコアに科目がなければ追加し点数もいれる

実行結果 ソース # scoresに登録がない場合は科目と点数を登録する scores = {'network': 60,'database': 80, 'security': 50} key = input('追加する科目を入力してください>>') if key in scores: print('すでに登録済みです') else: data = int(input('得…

(*´ω`) Python は便利だなあ。

実行結果 ソース(ジュースを含む文字列はみな好き) #トマトジュースも好きですよ name = input('あなたの名前を入力してください>>') print('{}さん、こんにちは'.format(name)) food = input('{}さんの好きな食べ物を教えてください>>'.format(name)) if …

(*´ω`)60点以上は ’合格’ 。それ以外は ‘不合格’と表示する

実行結果 ソース score = int(input('試験の点数を入力してください>>')) if score >= 60: print('合格') print('よくがんばりましたね') else: print('不合格') print('追試を受けてください') print(' ∧ ∧ you are genius')print('( ゚Д゚)')print('海と猫が…

(*´ω`) 

実行結果 ソース #私も好きですよ name = input('あなたの名前を入力してください>>') print('{}さん、こんにちは'.format(name)) food = input('{}さんの好きな食べ物を教えてください>>'.format(name)) if food == 'カレー': print('素敵です。カレーは最…

(*´ω`)

実行結果 ソース #私も好きですよ name = input('あなたの名前を入力してください>>') print('{}さん、こんにちは'.format(name)) food = input('{}さんの好きな食べ物を教えてください>>'.format(name)) print('私も{}が好きですよ'.format(food)) print(' …

(*´Д`) 共通部分を見つけるよ。

# 趣味の共通点 member_hobbies = { '松田' : {'apple','peach','lemon'}, '浅木' : {'orange','banana','peach'} } common_hobbies = member_hobbies['松田'] & member_hobbies['浅木'] print(common_hobbies) print(' ∧ ∧ New corona, pandemic')print('( …

# 点数管理 scores = [70,80,55] print(scores)print(scores[0]) print('要素数は{}'.format(len(scores)))print('合計は{}'.format(sum(scores))) print(' ∧ ∧ good job!')print('( ゚Д゚)')print('海と猫が好き')

SUM関数

# 点数管理 scores = [88,90,95] total = sum(scores) avg = total / 3 print('合計点は{},平均点は{}'.format(total,avg)) print(' ∧ ∧ good job!')print('( ゚Д゚)')print('海と猫が好き')

# 点数管理 network = 88database = 95security = 90 total = network + database + security avg = total / 3 print('合計点は{}'.format(total))print('平均点は{}'.format(avg)) print(' ∧ ∧ good job!')print('( ゚Д゚)')print('海と猫が好き')

# 割り勘計算 price = int(input('料金を入力>>'))number = int(input('人数を入力>>'))payment = int(price / number)print('お支払いは{}円です'.format(payment)) print(' ∧ ∧ good job!')print('( ゚Д゚)')print('海と猫が好き')