Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

14
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?

More than 5 years have passed since last update.

文系非エンジニアがPython触ってみた(基礎演算編)

Last updated at Posted at 2018-12-20

この記事は ハンズラボAdvent Calendar 2018
21日目の記事です。

ハンズラボの非エンジニア、マーケ&採用担当の @yuka_jyotei です。
この記事では、「文系非エンジニア(プログラミング経験なし)が、Pythonをやってみた」内容を紹介します。
超、基礎演算編です。

###事前にやったこと

・Pythonインストール
・ターミナル起動

###Pythonのバージョン確認

python -V

Python 2.7.10

とりあえず

print('Hello World!')

Hello World!

無事できました。

###変数の定義
変数を定義する。
”変数名=値”
これだけでできました。

x=1
これだけで、xと打つと「1」と出てきます。
とてもわかりやすいです。

y=2
として
x,y
と入れると
1,2
と出てきました。

###四則演算

演算子 演算の内容 演算の例
* 乗算(掛け算) 3 * 4
/ 除算(割り算) 9 / 3
+ 加算(足し算) 2 + 5
- 減算(引き算) 6 - 1

Excelと同じ感じですね。

###演算、もう少し複雑なもの

演算子 演算の内容 演算の例
// 除算(割り算) 9.0 // 3 = 3.0
% 余剰(割り算の余り) 7 % 2
** べき乗 5 ** 2

「//」 の演算子の場合は、
13 // 3
= 4
となり、
13.0 // 3
= 4.0
となります。小数点以下は切り捨てられています。

なお、「 / 」を使った場合
13.0 / 3
= 4.333333333333333
となりました。

「%」の余剰は、左側の数字を、右側の数字で割った余りが表記されます。
7 % 2
= 1
7÷2=3余り1です。

「 ** 」のべき乗は、左側の数字を、右側の数字で累乗したものが表記されます。
6 ** 2
= 36
6の2乗は、36です。

基礎中の基礎ですが、ここで力尽きたので、また続きは次回やります。
ありがとうございました。

###参考にさせていただいた記事です(ありがとうございました)

【Python入門】Pythonの基本操作 – Python初心者勉強記001
http://bb-biz.com/python-001/

【Python入門】Pythonの基本操作 – Python初心者勉強記002
http://bb-biz.com/python-002/

四則演算 - 数値 - Python入門 - Java Drive
https://www.javadrive.jp/python/num/index2.html

ハンズラボAdvent Calendar 2018 の22日目は、 @zizi4n5さんです!

14
0
2

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
14
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?