ソースコード
#coding:utf-8;
#最初プロがラム:変数の変数型 (type)
import os
import math
os.system("clear")
os.system("pwd")
# 数値 too 代入 ASSIGNMENT
a = 1;
print(type(a),"a=",a);
b = 2.23;
print(type(b),"b=",b);
c= a+b;
# 文字と文字列
a="h"
print(type(a),"a=",a);
a="h"
print(type(a),"a=",a);
a="hello world"
print(type(a),"a=",a);
a="1234254364"
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= a>=b;
print(type(c),"c=",c);
c= a!=b;
print(type(c),"c=",c);
c= a>b;
print(type(c),"c=",c);
c= bool(1);
print(type(c),"c=",c);
c= bool(0);
print(type(c),"c=",c);
# 四則演算
print(2*3+4*5)
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*r*r
area=math.pi*math.pow(r,2)
print(f"半径={r} 面積={area:.2f}")
lenth= 2*math.pi*r
print(f"半径={r} 周長={lenth:.2f}")
# First product
product_name = "りんご"
apple_price = 190
tax_rate = 0.08
qty = 5
total_price = (1 + tax_rate) * apple_price * qty
print(f"{product_name} {total_price:.0f} 円\n 単価 {apple_price}円 消費税 {tax_rate}購入個数 {qty}")
# Second product
product_name = "洗剤"
detergent_price = 230
tax_rate = 0.10
qty = 2
total_price = (1 + tax_rate) * detergent_price * qty
print(f"{product_name} {total_price:.0f} 円\n 単価 {detergent_price}円 消費税 {tax_rate} 購入個数 {qty}")