自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(38)
  • 收藏
  • 关注

原创 小程序-通讯录

一个通讯录小程序import cPickle as pclass addrlist(object): """This is address list""" storage = {} population = 0 def __init__(self, name, phone_num): """creat new one""" self.n

2017-12-19 16:58:54 2811 2

原创 《笨办法学python》加分习题42——我的答案

这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢!原文例题# -- coding: utf-8 --from sys import exitfrom random import randintclass Game(object): # 类内初始化,其中新建初始值quips和start def __init__(self, sta

2017-10-26 15:35:54 1324

原创 《笨办法学python》加分习题41——我的答案

这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢!原文例题:from sys import exitfrom random import randintdef death(): quips = ["You died. You kiinda suck at this.", "Nice job, you died ...jackass.

2017-09-13 23:54:57 1960 7

原创 《笨办法学python》加分习题40——我的答案

这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢!文中例题:cities = {'CA': 'San Francisco', 'MI': 'Detroit', 'FL': 'Jacksonville'}cities['NY'] = 'New York'cities['OR'] = 'Portland'def find_city(themap, state): i

2017-09-13 00:27:54 1054

原创 《笨办法学python》加分习题39——我的答案

这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢!原文例题:ten_things = "Apples Oranges Crows Telephone Light Sugar"print "Wait there's not 10 things in that list, let's fix that."stuff = ten_things.split(' ')more_s

2017-09-11 23:39:47 913

原创 《笨办法学python》加分习题37——我的答案

这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢! Keywords(关键字) 意义 and 与 del 删除 from 目前看来都跟着import,大体意思是从哪里拿出些什么 not 非 while while循环,当怎么样怎么样 as with…as:包含enter()和exi

2017-09-10 11:29:55 922

原创 《笨办法学python》加分习题36——我的答案

本来想说写个中文的行不行,果然试试是不行的,哈哈哈哈 # -- coding: utf-8 --from sys import exitdef morning(): print "清晨的一缕阳光洒下,你懒慵慵的伸了个懒腰..." answer = raw_input("你想? > ") if "起床" or "上班" in answer: go_work()

2017-09-06 22:27:43 696

原创 《笨办法学python》加分习题35——我的答案

这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢!ex34我没有什么想法,所以就不更这个。原文例题:from sys import exitdef gold_room(): print "This room is full of gold. How much do you take?" next = raw_input("> ") if "0" in

2017-09-05 00:20:31 1461

原创 《笨办法学python》加分习题33——我的答案

这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢!**原文例题:**i = 0numbers =[]while i < 6: print "At the top i is %d" % i numbers.append(i) i += 1 print "Numbers now: ", numbers print "At the bott

2017-09-03 22:32:33 834

原创 《笨办法学python》加分习题32——我的答案

这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢!**原文例题:**the_count = [1, 2, 3, 4, 5]fruits = ['apples', 'oranges', 'pears', 'apricots']change = [1, 'pennies', 2, 'dimes', 3, 'quarters']# this first kind of fo

2017-09-03 21:12:46 906

原创 《笨办法学python》加分习题31——我的答案

这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢!**原文例题:**print "You enter a dark room with two doors. Do you do through door #1 or door #2?"door = raw_input("> ")if door == "1": print "There's a giant bear

2017-09-03 20:20:08 552

原创 《笨办法学python》加分习题30——我的答案

这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢!原文例题:people = 30cars = 40buses = 15if cars > people: print "We should take the cars."elif cars < people: print "We should not take the cars."else:

2017-08-30 23:15:07 442

原创 《笨办法学python》加分习题29——我的答案

这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢!文中例题:people = 20cats = 30dogs = 15if people < cats: print "Too many cats! The world is doomed!"if people > cats: print "Not many cats! The world is sav

2017-08-30 17:47:46 599 1

原创 《笨办法学python》加分习题28——我的答案

这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢!文中例题:True and TrueFalse and True1 == 1 and 2 == 1"test" == "test"1 == 1 or 2 != 1True and 1 == 1False and 0 != 0True or 1 == 1"test" == "testing"1 != 0 and 2 ==

2017-08-30 17:00:09 465

原创 《笨办法学python》加分习题26——我的答案

停了一周多了吧,怪自己没恒心。又一次停这么久,真是抱歉,最近手头事比较多,可能目前也就是短短续续的更一些。总而言之,我对自己很抱歉。我自己改正后的程序: 先感谢下菜鸟教程和廖雪峰教程,非常好!# -- coding: utf-8 --import ex25def break_words(stuff): """This function will break up wor

2017-08-30 15:53:13 589

原创 《笨办法学python》加分习题25——我的答案

这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢!文中例题:def break_words(stuff): """This function will break up words for us.""" words = stuff.split(' ') return wordsdef sort_words(words): """Sorts

2017-08-22 07:50:02 1690 3

原创 《笨办法学python》加分习题24——我的答案

文中例题:print "Let's practice everything."print 'You\'d need to know \'bout escapes with \\that do\n newlines and \t tabs.'poem = """\tThe lovely worldwith logic so firmly plantedcannot discern \n the

2017-08-20 23:08:32 495 2

原创 《笨办法学python》加分习题21——我的答案

这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢!文中例题:def add(a, b): print "ADDING %d + %d" % (a, b) return a + bdef subtract(a, b): print "SUBTRACTING %d - %d" % (a, b) return a - bdef multiply(

2017-08-20 22:15:49 1196

原创 《笨办法学python》加分习题20——我的答案

这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢!文中例题:from sys import argvscript, input_file = argvdef print_all(f): print f.read()def rewind(f): f.seek(0)def print_a_line(line_count, f): print line_

2017-08-19 10:55:47 1640

原创 《笨办法学python》加分习题19——我的答案

这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢!文中例题:def cheese_and_crackers(cheese_count, boxes_of_crackers): print "You have %d cheeses!" % cheese_count print "You have %d boxes of crackers!" % boxes_

2017-08-19 10:36:20 1509 3

原创 《笨办法学python》加分习题18——我的答案

这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢!原文例题# this one is like your scripts with argvdef print_two(*args): arg1,arg2 = args print "arg1: %r, arg2: %r" % (arg1, arg2)# ok, that *args is actually

2017-08-17 22:31:14 702

原创 《笨办法学python》加分习题17——我的答案

这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢!文中例题:from sys import argvfrom os.path import existsscript, frome_file, to_file = argvprint "Coping from %s to %s" % (frome_file, to_file)# we could do these two

2017-08-16 23:03:49 3446

原创 《笨办法学python》加分习题16——我的答案

这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢!文中例题:from sys import argvscript, filename = argvprint "We're going to erase %r." % filenameprint "If you don't want that, hit CTRL-C (^C)."print "If you do want

2017-08-15 23:10:00 1505 3

原创 《笨办法学python》加分习题15——我的答案

这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢!文中例题:from sys import argvscript, filename = argvtxt = open(filename)print "Here's your file %r:" % filenameprint txt.read()print "Type the filename again:"file

2017-08-15 22:01:01 1542 1

原创 《笨办法学python》加分习题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 questio

2017-08-14 22:16:30 762 5

原创 《笨办法学python》加分习题13——我的答案

这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢!文中例子:from sys import argvscript, firsrt, secend, third = argvprint "The script is called:", scriptprint "Your first variable is:", firsrtprint "Your second vari

2017-08-14 10:39:03 1846

原创 《笨办法学python》加分习题12——我的答案

这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢!练习答案:1、如图所示: 大概意思应该是说将输入读成字符串,并且剔除行末的换行符。 3、其实看第一题的意思就大概知道pydoc就是python的帮助手册,所以想知道pydoc是干嘛的,直接pydoc pydoc应该就能知道。如图: 也是说是python的帮助手册。 4、这里好些图都好长,我就放图短的。。。

2017-08-13 23:45:54 535

原创 《笨办法学python》加分习题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'r

2017-08-13 22:51:34 779

原创 《笨办法学python》加分习题10——我的答案

大家多指点,多指点!原文练习:tabby_cat = "\tI'm tabbed in."persian_cat = "I'm split\non a line."backslash_cat = "I'm \\ a \\ cat."fat_cat = """I'll do a list:\t* Cat food\t* Fishies\t* Catnip\n\t* Grass"""pri

2017-08-11 09:26:40 771

原创 《笨办法学python》加分习题9——我的答案

新手上路,望大家多加提醒!原文练习:#Here's some new strange stuff, remenber type it exactly.days = "Min Tue Wed Thu Fri Sat Sun"months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug"print "Here are the days: ", daysprint

2017-08-10 23:29:42 513

原创 《笨办法学python》加分习题8——我的答案

今天这个比较少,也挺简单的。 还是那句话,新手上路,望大家多加指点!原文练习:# -- coding: utf-8 --formatter = "%r %r %r %r"print formatter % (1, 2, 3, 4)print formatter % ("one", "two", "three", "four")print formatter % (True, False, F

2017-08-10 23:20:16 800

原创 《笨办法学python》加分习题7——我的答案

加油吧,虽然目前都是简单的print。但作者一开始也交代了,肯定有他的意图。 还是很感谢这些无私奉献的大牛们!感谢,比心! 还是一样的话,新手上路,难免翻车,望大家能够批评指出,万分感谢!**书中练习:**#-- coding: utf-8 --print "Mary had a little lamb."print "Its fleece was white as %s." % 'snow

2017-08-10 22:30:48 589

原创 《笨办法学python》加分习题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."

2017-08-10 13:47:54 1142

原创 《笨办法学python》加分习题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'

2017-08-09 23:32:42 2194

原创 《笨办法学python》加分习题4——我的答案

首先是对自己感到抱歉,居然没坚持下去!初学者自娱自乐,感谢大家指正!开始正文:0、根据文中的意思,就是说在line 8的average_passengers_per_car = car_pool_capacity / passenger 中的car_pool_capacity是没有被定义的!作者故意打错了。1、我认为没有必要,space_in_a_car所进行的计算

2017-08-09 22:29:40 1676

原创 《笨办法学python》加分习题3——我的答案

#!/usr/bin/python print "I will now count my chickens:"print "Hens",25+30/6print "Roosters",100-25*3%4print "Now I will count the eggs:"print 3+2+1-5+4%2-1/4+6print "Is it true that 3+2<5-7?

2017-08-04 16:02:45 1252

原创 《笨办法学python》加分习题2——我的答案

1、同加分习题1中(3、)的答案, # 的主用在python中是为了注释代码,方便阅读和重拾! # 又名 井 、octothorpe 、pound character2、

2017-08-03 22:58:41 757

原创 《笨办法学python》加分习题1——我的答案

2018年08月03日,今天开始学习python。同学推荐了《笨办法学python》这本书,所以从今天开始以这本书开始学习python,也会将自己所做的答案给出,相当于复习。在此,感谢这本书的作者:Zed Shaw以及译者的贡献,非常感谢!同时感谢我的同学@xiebin6163。新手上路,难免翻车!还望前人指路,大家共同交流!正片:1、print "Hello World!"pr

2017-08-03 22:40:05 1535

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除