変数とデータ形と演算

ソースコード

#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="""
けすいけ
ニュン
トウグス
西
リオン
アシャン
ホアン
"""
print(a)

#文字と
a='h'
print(type(a),"a=",a)
a="h"
print(type(a),"a",a)
a="hello world!"
print(type(a),"a",a)
a="12131313131312313123"
print(type(a),"a",a)

#論理的データ   (真true,為false)
a=18
b=20
c= a==b
print(type(c),"c=",c)
c= a>=b
print(type(c),"c=",c)
c= a!=b
print(type(c),"c=",c)

#4側横算

print(2*3+4*5/2)

#出力関数
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="林檎"
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} ')
product_name="洗剤"
apple_price=230
tax_rate=0.10
qty=2
total_price=(1+tax_rate)*apple_price*qty
print(f'{product_name}        合計 {total_price:.0f}円\n 単価 {apple_price}円    消費税{tax_rate}    数量{qty} ')

実行結果