Python အမျိုးအစားပြောင်းခြင်း။
ကူးပြောင်းခြင်းကို ရိုက်ထည့်ပါ။
int()
၊
float()
နှင့် complex()
နည်းလမ်းများ ဖြင့် သင်သည် အမျိုးအစားတစ်ခုမှ အခြားတစ်ခုသို့ ပြောင်းနိုင်သည် -
ဥပမာ
အမျိုးအစားတစ်ခုမှ အခြားတစ်မျိုးသို့ ပြောင်းပါ-
x = 1 # int
y = 2.8 # float
z = 1j # complex
#convert from int to float:
a = float(x)
#convert from float to int:
b = int(y)
#convert from int to complex:
c = complex(x)
print(a)
print(b)
print(c)
print(type(a))
print(type(b))
print(type(c))
မှတ်ချက်- ရှုပ်ထွေးသောနံပါတ်များကို အခြားနံပါတ်အမျိုးအစားသို့ ပြောင်းလဲ၍မရပါ။