LoginSignup
0
0

More than 3 years have passed since last update.

今日の積み上げ python 学習記録#1

Last updated at Posted at 2020-11-27

本日の学習6:30~8:30


def print_hand(hand, name='ゲスト'):

    hands = ['グー','チョキ','パー']


    print(name + 'は' +hands[hand] + 'を出しました')

print('じゃんけんをはじめます')
player_name = input('名前を入力してください:')

print('何を出しますか?(0: グー, 1: チョキ, 2: パー)')


player_hand =int(input('数字で入力してください:'))

if player_name == '':

    print_hand(player_hand)
else:

    print_hand(player_hand, player_name)

int関数で整数化したinput関数の戻り値を変数player_handに代入しその変数を定義した関数print_handの第一引数に割り当てるのが味噌でした。

本業の仕事を昼までしたらまたお昼からぼちぼち遊びます。


class MenuItem:
    # 引数「name」と「price」を受け取るようにしてください
    def __init__(self,name,price):
        # 「サンドイッチ」の代わりに引数nameの値を代入してください
        self.name = name

        # 500」の代わりに引数priceの値を代入してください
        self.price = price

    def info(self):
        return self.name + ': ¥' + str(self.price)

    def get_total_price(self, count):
        total_price = self.price * count
        return total_price


# 引数を「サンドイッチ」と「500」としてください
menu_item1 = MenuItem('サンドイッチ',500)

print(menu_item1.info())

result = menu_item1.get_total_price(4)
print('合計は' + str(result) + '円です')

本日の夕方の学習
progateにて クラス インスタンス インスタンス変数 init ここら辺が一番苦手かも!!
おさないさんの動画でも写経ばかりしてました。何回か復習必要そうですね!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0