python独学 関数で引数を使う方法 2019年10月6日 atarundesukoryaku 当たるんです攻略サイト 関数で引数を使う方法 def hello(name): print("こんにちは"+name+"さん") hello("太郎") こんにちは太郎さん …
python独学 関数を定義する方法 2019年10月6日 atarundesukoryaku 当たるんです攻略サイト 関数を定義する方法 def say(): print("こんにちは") say() 関数を定義するには、defを使う。 defのあとに、関数名():を …
python独学 間違えたことまとめ 2019年10月6日 atarundesukoryaku 当たるんです攻略サイト 間違えたことまとめ 〜以上と指定するのを>=でなく、>としていた。 数値を文字列にするのはstr() 文字列を数字にするのがint() …
python独学 数値と文字列は連結できない? 2019年10月6日 atarundesukoryaku 当たるんです攻略サイト 数値と文字列は連結できない? 数値と文字列を連結することはできません。 print("りんごは"+30+"円です") なので、これは動きません。 p …
python独学 continueの使い方 2019年10月6日 atarundesukoryaku 当たるんです攻略サイト continueの使い方 continueを使うと、その周だけ繰り返しを飛ばすことができる。 ある条件を満たす時だけ、処理を実行したくない時に使う。 number …
python独学 breakの使い方 2019年10月6日 atarundesukoryaku 当たるんです攻略サイト breakの使い方 breakは強制的に繰り返し処理を終了させることができる。 numbers=[1,2,3,4,5,6,7] for number in numbe …
python独学 whileの使い方 2019年10月6日 atarundesukoryaku 当たるんです攻略サイト whileの使い方 x=1 while x<10: print(x) x+=1 1 2 3 4 5 6 7 8 9 と出力され …
python独学 辞書でfo in構文を使う方法 2019年10月6日 atarundesukoryaku 当たるんです攻略サイト 辞書でfo in構文を使う方法 fruits={“apple”:”red”,”lemon”:”yellow”} for fruit in fruits: print( …
python独学 辞書に数値を入れる方法 2019年10月6日 atarundesukoryaku 当たるんです攻略サイト 辞書に数値を入れる方法 price={"apple":100,"soda":150} price["egg"]=200 というように、辞書に数値を入れることも …
python独学 辞書に追加する方法 2019年10月6日 atarundesukoryaku 当たるんです攻略サイト 辞書に追加する方法 fruits={“apple”:”red”,”lemon”:”yellow”} fruits["strawberry"]="pink" …