《笨方法学Python》
威胁狩猎与分析
威胁狩猎与分析
展开
-
习题1--第一个程序
一:代码print "Hello World!"print "Hello Again"print "I like typing this."print "This is fun."print "Yay! Printing."print "I'd much rather you 'not'."print 'I "said" do not touch this.'二:附加练习原创 2016-09-24 00:25:38 · 560 阅读 · 0 评论 -
习题15--读取文件
这个习题涉及写两个文件:一个是正常的ex15.py文件,另外一个是ex15_sample.txt下面是该文本内容:This is stuff I typed into a file.It is really cool stuff.Lots and lots of fun to have in here.一:代码from sys import argvscript, file原创 2016-10-17 00:58:24 · 3037 阅读 · 0 评论 -
习题14--提示和传递
一:代码from sys import argvscript, user_name = argvprompt = '> 'print "Hi %s, I'm the %s script." % (user_name, script)print "I'd like to ask you a few questions."print "Do you like me %s?" % us原创 2016-10-16 23:02:44 · 480 阅读 · 0 评论 -
习题11--提问
一:代码print "How old are you?",age = raw_input()print "How tall are you??",height = raw_input()print "How much do you weigh?",weight = raw_input()print "So, you're %r old, %r tall and %r heavy.原创 2016-09-28 23:25:10 · 416 阅读 · 0 评论 -
习题10--转义字符
一:代码# _*_ coding:utf-8 _*_tabby_cat = "\tI'm tabbed in." # \t水平制表符persian_cat = "I'm split\non a line." # \n 换行符backslash_cat = "I'm \\ a \\ cat."fat_cat = """I'll do a list:\t* Cat food\t*原创 2016-09-26 22:55:28 · 2204 阅读 · 0 评论 -
习题9--打印,打印,打印
一:代码# Here's some new strange stuff, remember type it exactly.days = "Mon Tue Wed Thu Fri Sat Sun"months = "Jan\nFed\nMar\nApr\nMay\nJun\nJul\nAug"print "Here are the days: ",daysprint "Here a原创 2016-09-26 22:51:00 · 323 阅读 · 0 评论 -
习题8--打印,打印
一:代码formatter = "%r %r %r %r"print formatter % (1, 2, 3, 4)print formatter % ("one", "two", "three", "four")print formatter % (True, False, False, True)print formatter % (formatter, formatter,原创 2016-09-26 22:48:30 · 367 阅读 · 0 评论 -
习题13--参数、解包和变量
一:代码from sys import argvscript, first, second, third = argvprint "The script is called:", scriptprint "Your first variable is:", firstprint "Your second variable is:", secondprint "Your third原创 2016-10-11 23:54:02 · 1727 阅读 · 0 评论 -
习题7--更多打印
一:代码print "Mary had a little lamb."print "Its fleece was white as %s." % 'snow'print "And everywhere that Mary went."print "." * 10 # what'd that do?end1 = "C"end2 = "h"end3 = "e"end4 = "e"原创 2016-09-25 20:37:18 · 453 阅读 · 0 评论 -
习题6--字符串和文本
一:代码x = "There are %d types of people." % 10binary = "binary"do_not = "don't"y = "Those who know %s and those who %s" % (binary, do_not)print xprint yprint "I said: %r." % xprint "I also sa原创 2016-09-24 23:36:04 · 945 阅读 · 0 评论 -
习题5--更多的变量和打印
一:代码my_name = 'Zed A. Shaw'my_age = 35 # not a liemy_height = 74 #inchesmy_weight = 180 # lbsmy_eyes = 'Blue'my_teeth = 'White'my_hair = 'Brown'print "Let's talk about %s." % my_nameprint "原创 2016-09-24 00:53:03 · 740 阅读 · 0 评论 -
习题4--变量和命名
一:代码cars = 100space_in_a_car = 4.0drivers = 30passengers = 90cars_not_driven = cars - driverscars_driven = driverscarpool_capacity = cars_driven * space_in_a_caraverage_passengers_per_car = p原创 2016-09-24 00:38:35 · 436 阅读 · 0 评论 -
习题3--数字与数学计算
一:代码print "I will now count my chickens:"print "Hens", 25 + 30 / 6print "Rooters", 100 - 25 * 3 % 4print "Now I will count the eggs:"print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6print "Is it true原创 2016-09-24 00:35:20 · 889 阅读 · 1 评论 -
习题2--注释和#符号
一:代码:# A comment, this is so you can read your program later.# Anything after the # is ignored by python.print "I could have code like this." # and the comment after is ignored# You can also us原创 2016-09-24 00:29:10 · 474 阅读 · 0 评论 -
习题12--raw_input()提示别人
对于raw_input()而言,你可以让它显示出一个提示,从而告诉别人应该输入什么。一:代码age = raw_input("How old are you? ")height = raw_input("How tall are you? ")weight = raw_input("How much do you weight? ")print "So, you're %r old原创 2016-10-08 07:53:28 · 2352 阅读 · 1 评论