読み込んだ2つの実数値の 和・差・積・商 を実数で表示

明解C言語 入門編 > 2. 演算と型 >

読み込んだ2つの実数値の 和・差・積・商 を実数で表示

Python
# coding: Shift_JIS

print "2つの数を入力してください。"

vx = raw_input("実数1:")
vy = raw_input("実数2:")

print "vx + vy = ", str(float(vx) + float(vy))
print "vx - vy = ", str(float(vx) - float(vy))
print "vx * vy = ", str(float(vx) * float(vy))
print "vx / vy = ", str(float(vx) / float(vy))

実行結果

N:\>python lesson_02_011.py
2つの数を入力してください。
実数1:40.5
実数2:5.2
vx + vy = 45.7
vx - vy = 35.3
vx * vy = 210.6
vx / vy = 7.78846153846