Important Announcement
PubHTML5 Scheduled Server Maintenance on (GMT) Sunday, June 26th, 2:00 am - 8:00 am.
PubHTML5 site will be inoperative during the times indicated!

Home Explore python

python

Published by Tony Silverlight, 2018-01-27 09:21:02

Description: python

Search

Read the Text Version

Python เป็นภาษา script และเป็นภาษาทีRaspberry PIแนะนาํ ใหใ้ ชด้ ว้ ย สังเกตุไดว้ า่ มีไลบรารีในการเชือมต่อฮาร์ดแวร์ออกมามากและตวั อยา่ งหลายๆ ตวั บนRaspberry PI กม็ กั จะเป็น Python

print “HelloWorld”คาํ สังในการแสดงผลของ Python

var_int = 10 var_float = 20.00var_str = “hellopython”Python ไม่ต้องประกาศ Type หน้าตัวแปร

data = 10 print dataคาํ สัง print สามารถใช้กบั ตวั แปรได้ด้วย

ชุดคาํ สังทางคณติ ศาสตร์ของ Python เบืองต้นไล่จากซ้าย บวก ลบ คูณ หาร + , - , *, /, // ,%ตัวอย่าง a=a+1 b = 20 - 10 c=1*5 d=4/2

==, >=, >, <, <=สัญลกั ษณ์ในการตดั สินใจเบืองต้น == เท่ากบั >= มากกว่าหรือเท่ากบั > มากกว่า < น้อยกว่า <= น้อยกว่าหรือเท่ากบั

if, else และการตัดสินใจx = 10if x > 10 : print “x is too small”else : print “x is too big”

while loop เพือใช้ในการวนลปูx=0while x < 10 : print “helloWorld” x=x+1

ฟังก์ชันและการใช้งานเบืองต้นdef plus_function(n1, n2) : return n1 + n2print plus_function(2,3)

วิธกี ารสร้างไฟล์ Python• nano helloworld.pyเปิดไฟล์เพือ edit และเขียนโค้ด• python helloworld.pyเป็นการรันไฟล์โปรแกรมด้วย python interpreter• sudo python helloworld.pyเวลา access hardware หรือกระทํากบั ไฟล์ทีมีpermission ให้รัน python ด้วย sudo


Like this book? You can publish your book online for free in a few minutes!
Create your own flipbook