python 掌握之路(一)

来源:互联网 发布:站长 疯狗软件 编辑:程序博客网 时间:2024/05/03 09:14
#!/usr/bin/env python# -*- coding: utf-8 -*-# use case 1: the first python programprint "hello world";# use case 2: the second python program : use keyword :forfor i in range(10):    print str(i)+"hello worldww";print "add";# use case 3: the second python program : use keyword for (2. write mult lines)for i in range(10):    print str(i)+"hello worldww";    print "add";# use case 4: multLine annotation'''print "multline ";'''#use case 5: pint a string of stringprint "hello world " , "secod string " ,"third string ";#use case 6 : print calulateprint '3+5 =' , 3+5 ;#use case 7: input a string'''name = raw_input();print 'the name is value :',name ;#use case 8: input a string with informationname = raw_input('please input a name');print 'the name is value :',name ;'''#use case 9: print absolute value of a integer (use the key word of if )a=100if a>=0:    print a;else:    print -a;#use case 10: print ' or ""print '\"i\'m enjoy pthon \"';#use case 11 : use +x = 100;x = x+300;print x;x ="a string";print x;#use case 12: about int and floatprint 10/3;print 10.0/3;print 10%3;print 10.0%3;#use case 13: out of range of variableb ='B';b = 65574; # haven't out of range . good !b = 898888888;print b ;#use case 14: ACSII code ,UNICODE'''#!/usr/bin/env python# -*- coding: utf-8 -*-'''print ord('T'),chr(100) , unicode('T'), len('hello'),len(unicode('hello')),len(unicode("你好".decode('utf-8'))) , "你好";#use case 15 , connect stringprint "the nuber i want to enter is %d , the name of mine is %s"%(7 , "liujie");
0 0
原创粉丝点击