#!/usr/bin/python
#coding=utf-8
class switch(object):
def __init__(self, value):
self.value = value
self.fall = False
def __iter__(self):
yield self.match
raise StopIteration
def match(self, *args):
if self.fall or not args:
return True
elif self.value in args:
self.fall = True
return True
else:
return False
operator = "+"
x = 1
y = 2
for case in switch(operator):
if case('+'):
print x + y
break
if case('-'):
print x - y
break
if case('*'):
print x * y
break
if case('/'):
print x / y
break
if case():
print ""
#
print('Hello World !')
#
a = 1.3
#
print(a),type(a)
#
#
#a=10 int
#a=1.3 float
#a=True (True/False)
#a='Hello!'
#
#tuple
s1 = (2,1.3,10,'who',5.8,12,False)
#list
s2 = [True,5,'smile']
#
print(s1),(s2),type(s1),type(s2)
s2[0] = 3.1415926
print(s2)
print s1[:5]
print s1[2:]
print s1[0:5:2]
print s1[0:8:1]
print s1[7::-1]
#
str = 'abcdefghijklmnopqrstuvwxyz'
print str[2:4]
print str[0::1]
#
print 1+1
print 1-32
print 1.34*26
print 199/15
print 198%55
print 3**9
#
print 5 == 6
print 8.0!=8.0
print 3<3, 3<=3
print 4>5, 4>=0
c = 2.5
#
print a is not c
print True and True, True and False
print True or False
print not True
#
i = 1
if i > 0:
x = 1
y = 1
print x+y
#if
i = 1
if i != 1:
x = 5
y = 2
print x*y
else:
print 'somthing worry'
i = -2
x = 1
if i > 0:
x = x+1
print x
i = 6
if i > 0:
print 'positive i'
i = i + 1
if i > 2:
print 'i bigger than 2'
print 'even better'
elif i == 0:
print 'i is 0'
i = i * 10
else:
print 'negative i'
i = i - 1
print 'new i:',i