# 執行範例

``````>>> print("Hello!");
Hello!
>>> print("你好！")

>>> type("Hello!")
<class 'str'>
>>> type(3.14)
<class 'float'>
>>> type(7)
<class 'int'>
>>> msg = "Hello!"
>>> x = 7
>>> pi = 3.14
>>> type(msg)
<class 'str'>
>>> type(x)
<class 'int'>
>>> type(pi)
<class 'float'>
>>> r = 5
>>> pi * r * r
78.5
>>> print("半徑為 5 的圓，面積為"+pi*r*r)
Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
print("半徑為 5 的圓，面積為"+pi*r*r)
TypeError: Can't convert 'float' object to str implicitly
>>> print("半徑為 5 的圓，面積為"+str(pi*r*r))

>>> math.sin(pi/3)
Traceback (most recent call last):
File "<pyshell#15>", line 1, in <module>
math.sin(pi/3)
NameError: name 'math' is not defined
>>> import math
>>> math.sin(pi/3)
0.8657598394923444
>>> math.sqrt(2)
1.4142135623730951
>>> math.exp(math.log(2))
2.0
>>> def printHello() :
print("Hello!")

>>> printHello()
Hello!
>>> import math
>>> print math
SyntaxError: invalid syntax
>>> print(math)
<module 'math' (built-in)>
>>> print(e)
Traceback (most recent call last):
File "<pyshell#27>", line 1, in <module>
print(e)
NameError: name 'e' is not defined
>>> print(pi)
3.14
>>> from math import *
>>> print(pi)
3.141592653589793
>>> print("pi=", pi)
pi= 3.141592653589793
>>> 5==5
True
>>> 5==6
False
>>> type(True)
<class 'bool'>
>>> type(False)
<class 'bool'>
>>> x
7
>>> if (x>5) :
print 'x>5'

SyntaxError: invalid syntax
>>> if (x>5) :
print('x>5')

x>5
>>> if (x>5) :
print('x>5')
else :

SyntaxError: invalid syntax
>>> Help
Traceback (most recent call last):
File "<pyshell#46>", line 1, in <module>
Help
NameError: name 'Help' is not defined
>>> if (x>5) :
print('x>5')
else :
print('x<=5')

x>5
>>>```
```