1 my_name = 'Zed A. Shaw' 2 my_age = 35 # not a lie 3 my_height = 74 # inches 4 my_weight = 180 # lbs 5 my_eyes = 'Blue' 6 my_teeth = 'White' 7 my_hair = 'Brown' 8 9 print "Let's talk about %s." % my_name 10 print "He's %d inches tall." % my_height 11 print "He's %d pounds heavy." % my_weight 12 print "Actually that's not too heavy." 13 print "He's got %s eyes and %s hair." % (my_eyes, my_hair) 14 print "His teeth are usually %s depending on the coffee." % my_teeth 15 16 # this line is tricky, try to get it exactly right 17 print "If I add %d, %d, and %d I get %d." % ( 18 my_age, my_height, my_weight, my_age + my_height + my_weight)
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 #! usr/bin/env python 2 3 #-*- coding:utf-8 -*- 4 5 6 7 import string 8 9 10 11 alphas=string.letters+'_' 12 13 nums=string.digits 14 15 16 17 print u'欢迎使用一次性标识符检查器1.0版.' 18 19 print u'囧...\n暂时没找到检查结束后重回程序起点的办法.\n所以只好一次性了.' 20 21 print u'请输入至少两个字符.' 22 23 myinput=raw_input('>') 24 25 if len(myinput)>1: 26 27 if myinput[0] not in alphas: 28 29 print u'傻逼,输个这玩意都能出错?!' 30 31 else: 32 33 for otherchar in myinput[1:]: 34 35 if otherchar not in alphas+nums: 36 37 print u'傻逼,输个这玩意都能出错?!' 38 39 break 40 41 else: 42 43 print u'诶,好像不太对劲,让我再瞅瞅...啊呀呦,我勒个去!\n恭喜!合法标识符,鉴定完毕!'