print "Hello, World!"
ɾ Ͽ α Ϸ װ ؽƮ ȿ ŸϿ, װ hello.py ϰ ``python hello.py'' װ ϶.
IDLE , ο 츦 ϰ, װ 1.4 ۼ϶.
α Ǿ װ ϴ Ÿ:
Hello, World!
п Ź ̰ ̾߱ ʰڴ. п ϳ α شٸ, װ Ÿغ Ͽ ⸦ Ѵ. μ װ Ÿ , Ѵ.
α ִ:
print "Jack and Jill went up a hill" print "to fetch a pail of water;" print "Jack fell down, and broke his crown," print "and Jill came tumbling after."
α ϸ װ ϴ ٴ:
Jack and Jill went up a hill to fetch a pail of water; Jack fell down, and broke his crown, and Jill came tumbling after.
ǻͰ α ϸ װ :
print "Jack and Jill went up a hill" ǻͰ ϴ :
Jack and Jill went up a hill
ǻʹ ̰ :
print "to fetch a pail of water;"
ǻʹ ũ :
to fetch a pail of water;
ǻʹ Ǹ鼭, ɾ . ǻʹ α ϱ ɾ Ͽ Ѵ.
print "2 + 2 is", 2+2 print "3 * 4 is", 3 * 4 print 100 - 1, " = 100 - 1" print "(33 + 2) / 5 + 11.5 = ",(33 + 2) / 5 + 11.5
α Ǿ ִ:
2 + 2 is 4 3 * 4 is 12 99 = 100 - 1 (33 + 2) / 5 + 11.5 = 18.5
̽ õ¥ ǻ 5¥ ٲ ִ.
̽㿡 6 ⺻ ó ִ:
ó | ɺ | |
ȭ | ** |
5 ** 2 == 25 |
* |
2 * 3 == 6 |
|
/ |
14 / 3 == 4 |
|
% |
14 % 3 == 2 |
|
+ |
1 + 2 == 3 |
|
- |
4 - 3 == 1 |
Ģ ϶, Ҽ· ʾҴٸ, ݵ Ҽ· ʴ´. α ̰ ش:
print "14 / 3 = ",14 / 3 print "14 % 3 = ",14 % 3 print print "14.0 / 3.0 =",14.0 / 3.0 print "14.0 % 3.0 =",14 % 3.0 print print "14.0 / 3 =",14.0 / 3 print "14.0 % 3 =",14.0 % 3 print print "14 / 3.0 =",14 / 3.0 print "14 % 3.0 =",14 % 3.0 print:
14 / 3 = 4 14 % 3 = 2 14.0 / 3.0 = 4.66666666667 14.0 % 3.0 = 2.0 14.0 / 3 = 4.66666666667 14.0 % 3 = 2.0 14 / 3.0 = 4.66666666667 14 % 3.0 = 2.0Ҽ Ǿ° ƴѰ ̽ 鿡 ϰ ִ ָ϶.
ó п ̴:
()
**
*
, \
, %
+
-
α ϰ ߴ 巡 . ̷ Ͼ α Ƹ ּ ٿ߸ Ѵ. ּ а ٸ αӵ鿡 Ͼ ִ ִ ǥ̴. :
#Not quite PI, but an incredible simulation print 22.0/7.0ּ
#
۵ǰ ָ϶.
ּ α д ٸ ̵ ϱ ̸ ̷ ڽſ ͵ Ȯϰ ֱ ̴.
Denmark.py
print "Something's rotten in the state of Denmark." print " -- Shakespeare"
:
Something's rotten in the state of Denmark. -- Shakespeare
School.py
#This is not quite true outside of USA # and is based on my dim memories of my younger years print "Firstish Grade" print "1+1 =",1+1 print "2+4 =",2+4 print "5-2 =",5-2 print print "Thirdish Grade" print "243-23 =",243-23 print "12*4 =",12*4 print "12/3 =",12/3 print "13/3 =",13/3," R ",13%3 print print "Junior High" print "123.56-62.12 =",123.56-62.12 print "(4+3)*2 =",(4+3)*2 print "4+3*2 =",4+3*2 print "3**2 =",3**2 print
:
Firstish Grade 1+1 = 2 2+4 = 6 5-2 = 3 Thirdish Grade 243-23 = 220 12*4 = 48 12/3 = 4 13/3 = 4 R 1 Junior High 123.56-62.12 = 61.44 (4+3)*2 = 14 4+3*2 = 10 3**2 = 9