ソースコード
#coding:utf-8
#最初のプログラム:変数と変数の型(type)
import os
import math
os.system("clear")
#数値
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="232414567"
print(type(a),"a=",a)
a='''
小俣
ニュン
トゥグス
西
アシャン
ヤマグチ
ホアン
'''
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= bool(1)
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="林檎"
app_price=190
tax_rate=0.08
qty=5
total_price=(1+tax_rate)*app_price*qty
print(f'{product_name} {total_price:.0f}円 \n 単価 {app_price}円 消費税 {tax_rate} 購入個数 {qty}')
product_name="洗剤"
app_price=230
tax_rate=0.10
qty=2
total_price=(1+tax_rate)*app_price*qty
print(f'{product_name} {total_price:.0f}円 \n 単価 {app_price}円 消費税 {tax_rate} 購入個数 {qty}')