Skip to content

Instantly share code, notes, and snippets.

@ycku
Last active September 5, 2017 03:16
Show Gist options
  • Save ycku/f3142128fe5202a48682c87feecb8aaa to your computer and use it in GitHub Desktop.
Save ycku/f3142128fe5202a48682c87feecb8aaa to your computer and use it in GitHub Desktop.
Hello, Python
# 執行時自行註解掉不需要的段落
# 自動型別
var = 'Hello World' # string
print(var)
var = 100 # int
print(var+10)
print('-----')
# 沒有 overflow
var = 17**3000 # 17的3000次方
print(var)
print('-----')
# swap
a=1
b=2
c=3
print(a,b,c)
c,a,b=b,c,a
print(a,b,c)
print('-----')
# string index
var1 = 'Hello World'
var2 = "Python Programming"
print(var1[0]) # H, 從0開始
print(var2[1:5]) # "ytho", 1到小於5
print('-----')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment