0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Python入門

Last updated at Posted at 2024-12-23

Python入門

目次

  1. Pythonとは?
  2. Pythonのインストール
  3. 基本文法
  4. 簡単なプログラム例
  5. 次のステップ

Pythonとは?

Pythonは、シンプルで読みやすい文法を持つプログラミング言語。
主に次のような特徴がある:

  • 初心者に優しい:コードが直感的で分かりやすい。
  • 多用途:Web開発、データ分析、AIなど、幅広い分野で利用可能。
  • 豊富なライブラリ:便利なツールがたくさん用意されている。

Pythonのインストール

手順

  1. Python公式サイトにアクセス。
  2. 最新版のPythonをダウンロード。
  3. インストーラーを実行して、Add Python to PATHにチェックを入れてインストール。

defaultの場所にinstallするのではなく
C:/ とかに pythonフォルダ を作っておいてそこにインストールするのがいい

動作確認

ターミナルやコマンドプロンプトで次を実行:

python --version

正しくインストールされていれば、バージョン番号が表示される。


基本文法

変数とデータ型

例:

# 変数の宣言
x = 10      # 整数型
name = "Python"  # 文字列型
is_active = True  # ブール型

print(x, name, is_active)

条件分岐

例:

# if文の使い方
score = 85
if score >= 90:
    print("Aランク")
elif score >= 70:
    print("Bランク")
else:
    print("Cランク")

ループ

例:

# forループ
for i in range(5):
    print(i)

# whileループ
count = 0
while count < 5:
    print(count)
    count += 1

簡単なプログラム例

次のプログラムは、ユーザーの名前を入力して挨拶するもの:

# ユーザー入力を取得して挨拶
name = input("あなたの名前は何ですか?: ")
print(f"こんにちは、{name}さん!")

次のステップ


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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?