1
2

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の基礎を学びなおした記録①

Posted at

Pythonの基礎的な知識を身に付けたいと思い、改めて基礎から学び直していきます。

なぜテックブログとしてアウトプットするのか

世界一流エンジニアの思考法
こちらの本でも紹介されているように、基礎の部分を理解するのには時間がかかると思いました。
また、良い勉強方法として、何か新しいことを学んだらテックブログを書くことをオススメされていたので、学び直したことを記事にしてアウトプットしようと思ったのがきっかけです。

1.基本的な変数

以下を変数に入れる

  • 整数(int) number: 1
  • 文字列(string) text: "testtest"
  • 論理型(boolean) flag: True
  • None型 test: None
  • 浮動小数点数(float) pi: 3.14
number = 1
text = "testtest"
flag = True
test = None
pi = 3.14

2. 基本的な計算

整数型の2つの変数を宣言してください。2つの変数を用いて、足す、引く、かける、割る、割った余りを出力してください。

num_1 = 7
num_2 = 2


add_num = num_1 + num_2
sub_num = num_1 - num_2
mul_num = num_1 * num_2
div_num = num_1 / num_2
mod_num = num_1 % num_2

print("足し算:", add_num)
print("引き算:", sub_num)
print("掛け算:", mul_num)
print("割り算:", div_num)
print("割り算の余り:", mod_num)


出力結果
足し算: 9
引き算: 5
掛け算: 14
割り算: 3.5
割り算の余り: 1

ちなみに割り算に関しては///があります。
/の場合は小数点まで出力されます。
//の場合、小数点は出力されず、今回の例で言うと3と出力されます。

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?