首页 > 编程语言 > 详细

Think python(第二版)习题代码

时间:2018-03-09 21:55:09      阅读:580      评论:0      收藏:0      [点我收藏+]

3-2:

 

def do_twice(f, s1):
	f(s1)
	f(s1)

def print_spam(s2):
	print(s2)

def print_twice(s3):
	print(s3)
	print(s3)

def do_four(f1,f2,s4):
	f1(f2,s4)
	f1(f2,s4)

do_twice(print_twice, ‘aaa‘)

do_four(do_twice, print_spam, ‘spam‘)

 

3-3.1:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

def push1():
	print(‘+ - - - -‘, end = ‘ ‘)  # 默认情况下print会自动换行,可以在结尾打印一个空格改变这一行为

def push2():
	print(‘|        ‘, end = ‘ ‘)

def do_twice(f):
	f()
	f()

def do_four(f):
	f()
	f()
	f()
	f()

def row1():
	do_twice(push1)
	print(‘+‘)

def row2():
	do_twice(push2)
	print(‘|‘)

row1()
do_four(row2)
row1()
do_four(row2)
row1()

  

Think python(第二版)习题代码

原文:https://www.cnblogs.com/chunzhen/p/8536386.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!