#!/usr/bin/python
# -*- coding: utf-8 -*-
# Filename : helloworld.py
print u'使用單引號定義字串'
print u"使用雙引號定義字串"
print u'''使用三引號建立換行
第二行
第三行'''
print u'使用轉義符\''
print u'使用行末\來串連太長的一行字串\
過長部分字串'
print ur'使用r建立自然字串過濾轉義符\''
print u'Unicode符'
print u'兩個字串自動連接' u'第二個字串'
print u'歡迎到中國來!Hello World\''
# var
i = 5
print i
i = i + 1
print i
s = '''This is a multi-line string.
This is the second line.'''
print s
s = u'建立邏輯行,不以分號結尾'
print s
print \
s
# calc
print 2//3
print 20/3
print 20//3
print 20//3.0
print 20/3.0
print 2<<2
print 3<<2
print 4<<2
print 3>>2
print 4>>2
print 5>>2
print 6>>2
print 5&3
print 5^3
# 加號比與或符優先順序高
print 5&3 + 5^3 == 5|3
print 5&3 + 5^3
print (5&3) + (5^3)
print 5|3
print ~5
# x的值與y的值互換
x = 5
y = 3
x = x ^ y
y = y ^ x
x = x ^ y
print x
print y
x = ~(~0<<4)
y = x >> 4
print y & x
# 迴圈移位
a = ~0
b = a << (8 - 4)
c = a >> 4
c = c | b
print c
a = 0xAA
b = a << (8 - 4)
c = a >> 4
c = c | b
print c,a
a = 0x55
b = a << (8 - 4)
c = a >> 4
c = c | b
print c,a