Devdit
 

Python int to float ด้วยคำสั่ง float

1.3K

สอนเขียนภาษา Python เพื่อแปลง int to float ด้วยคำสั่ง float โดยคำสั่งนี้จะแปลงตัวแปรที่ต้องการให้อยู่ในรูปของทศนิยม หรือ float สามารถเขียนโปรแกรมได้ดังนี้

 

ตัวอย่าง Python int to float ด้วยคำสั่ง float

i = 89
print( type(i), i )
i = float(i)
print( type(i), i )

ผลลัพธ์

<class 'int'> 89
<class 'float'> 89.0
เขียน 2 ปีที่แล้ว
ชอบ
ลิ้งก์
แชร์
Devdit มีช่อง YouTube แล้ว
เราสร้างวิดีโอเกี่ยวกับเทคโนโลยี ทำตามง่ายๆ