นักเรียนสามารถทดลองเขียนโปรแกรมโดยใช้ฟังก์ชันทางคณิตศาสตร์ได้จากที่นี่...
#example
import math
x = math.sqrt(9)
print(x)
#you can test coding here
นักเรียนสามารถทดลองเขียนโปรแกรมโดยใช้ฟังก์ชันทางคณิตศาสตร์ได้จากที่นี่...
#example
>>>import math
>>>x = math.sqrt(9)
>>>print(x)
#you can test coding here
Print output (ตัวอย่างผลลัพธ์ที่ได้)
3.0
ตัวอย่างโปรแกรมรับค่าข้อความและแสดงผลออกทางหน้าจอ
1
import math
2
x1 = int(input("Input x1 : "))
3
y1 = int(input("Input y1 : "))
4
x2 = int(input("Input x2 : "))
5
y2 = int(input("Input y2 : "))
6
dif_x_pow2 = math.pow(x2-x1,2)
7
dif_y_pow2 = math.pow(y2-y1,2)
8
distance = math.sqrt(dif_x_pow2 + dif_y_pow2)
9
print("Distance is ",distance)
Print output (ตัวอย่างผลลัพธ์ที่ได้)
Input x1 : 5
Input y1 : 1
Input x2 : 6
Input y2 : 2
Distance is 1.4142135623730951