LoginSignup
0
0

More than 3 years have passed since last update.

ProgeteのPython学習コースⅠを受講してみた

Last updated at Posted at 2020-02-16

■プログラム

Pythonに触れてみよう
1. 目標物を確認しよう

Pythonの基礎を学ぼう
2. 文字列
3. 数値
4. 計算してみよう

・文字列を出力してみよう
 (例)print('hello Python')
 (ポイント)シングルorダブルクォーテーションで囲む
 
・数値
 (例)print(3)
 (ポイント)数字はクォ-テンションで囲まない

変数を使ってみよう
5. 変数
6. 変数を使ってみよう
7. 変数の値を更新してみよう
8. 文字列の連結
9. データ型

・変数
 (例)name = 'soarer'
    number = 48 

・変数名の付け方
 良い例
 (例)date 英単語を用いる
    user_name 2語以上の場合はアンダーバーで区切る

 悪い例
 (例)1name 数字開始
    namae ローマ字を用いる
    名前 日本語

・文字列の連結
 (例)print('Hallo' + 'Python')

・変数の値を更新する
 (例)x = 48
print(x)
x = 46 変数の値を上書き

・データ型
 (例)'Hello Python' 文字列型
    3 数値型

 (例)print(4 + 8) 数値の計算 結果12
    print('4' + '8') 文字の連結 結果48

・型変換 str
 (例)price = 100
    print('りんごの価格は' + price + '円です')
print('りんごの価格は' + str(price) + '円です')←strで文字列型に変換

・型変換 int
 (例)count = '48'
    price = 100
total_price = price * int(count)←数値型に変換

真偽値と条件分岐
10. if文
11. 真偽値
12. else
13. elif
14. 条件式を組み合わせよう

・if文の条件式
 (例)x == y 左右の値が等しい時成り立つ
    x != y 左右の値が等しくない時成り立つ 

・if文の条件式が成立した時の処理を書くときはインデント(字下げ)をします。

・真偽値

score = 100
if score == 100:←コロン

score = 100
print(score == 100)

True
False

print(3 == 3) True
print(3 == 5) False

score = 100
if score == 100: Trueが成立する

score = 50
if score == 100: Trueが成立しない

・else
 (例)score = 50
 if score == 100:←コロン
print('よくできました')←インデント
     else:←コロン
     print('頑張りましょう')

・elif
 (例)score = 70
 if score == 100:←コロン
print('よくできました')←インデント
     elif score >= 60:←コロン
     print('まずまずです')←インデント
     else:←コロン
     print('頑張りましょう')
 elifはいくつでも入れることができる
 最後はelseで終わる

お買い物代金を計算しよう
15. 代金を計算しよう
16. 入力を受け取ろう
17. 条件分岐をしよう

PythonⅠは初心者でも分かりやすいのでお勧めです。

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