変数とデータ型と演算

ソースコード
#coding:utf-8
#最初のプログラム:変数と変数の型(type)
import os
import math
    
os.system("clear")
os.system("pwd")
#数値
    
a=1
print(type(a),"a=",a)
b=2.23
print(type(b),"b=",b)
    
#文字と文字列
a='h'
print(type(a),"a=",a)
a="h"
print(type(a),"a=",a)
a="hello world!"
print(type(a),"a=",a)
a="28754861"
print(type(a),"a=",a)
    
#理論的なデータ (true真,false偽)
a=20
b=34
c= a==b
print(type(c),"c=",c)
    
c= a!=b
print(type(c),"c=",c)
    
c= bool(0)
print(type(c),"c=",c)
    
#四則演算
print(2*(3+4)*5/2)
a,b,c=12,23,45
print(a-b+c)
    
a,b=100,23
a *=b
print(a)
    
#出力関数のフォーマット(format)設定
r=50
area=math.pi*math.pow(r,2)
print(f'半径={r} 面積={area:.2f}')
    
lenth=2*math.pi*r
print(f'半径={r} 周長={lenth:.2f}')
    
product_name="林檎"
price=150
tax_rate=8/100
qty=5
total_price=(1+tax_rate)*price*qty
print(f'{product_name}       {total_price:.0f}円 /n 単価{price}円 消費税 {tax_rate} 購入個数 {qty}')
    
product_name="洗剤"
price=230
tax_rate=10/100
qty=2
total_price=(1+tax_rate)*price*qty
print(f'{product_name}       {total_price:.0f}円 /n 単価{price}円 消費税 {tax_rate} 購入個数 {qty}')
実行結果