% python Python 2.2.2 (#1, Oct 31 2002, 13:31:46) [GCC 2.95.3 20010315 (release)] on sunos5 Type "help", "copyright", "credits" or "license" for more information. >>> |
>>> 123 + 456 579 >>> 123 * 456 56088 >>> a = 234 >>> b = 567 >>> a * b 132678 >>> c = a + b >>> c * a 187434 >>> print 'Hello!' Hello! |
>>> ^D % |
% cd ~/coreinfo % mkdir python % cd python % dtpad a.py & |
import sys who = sys.argv[1] print 'Hello, %s!' % who |
% python a.py Tokio Hello, Tokio! |
#!/pub/sol8/bin/python import sys who = sys.argv[1] print 'Hello, %s!' % who |
% chmod +x a.py % ./a.py Rumiko Hello, Rumiko! |
#!/pub/sol8/bin/python # 専門コア情報処理演習教材 enzan.py, 2002 # は注釈文です。 import string, sys def enzan(a,b): print '実行' print ' a = %d' % a print ' b = %d' % b print 'a + b = %d' % (a + b) print 'a - b = %d' % (a - b) print 'a * b = %d' % (a * b) if b != 0: print 'a / b = %d 余り %d' % (a / b, a % b) if __name__ == '__main__': a = string.atoi(sys.argv[1]) b = string.atoi(sys.argv[2]) enzan(a, b) |
<a href="http://www.is.kochi-u.ac.jp/~tkikuchi/>菊地のホームページ