python编程:从入门到实践 课后题目(第二章)
2018-03-10 22:37
741 查看
2-1/2-2:message = "helloworld"
print(message)
message = "hello python"
print(message)2-3/2-4:user_name = "Galileo Galilei"
print('"Hello ' + user_name + ", would you like to learn\
some Python today?" + '"')
print(user_name.lower())
print(user_name.upper())
print(user_name.title())2-5/2-6:famous_person = "Galileo Galilei"
wisdom = "Life is like the anvil, the more to be beat, the more able to spark."
print(famous_person + 'once said,"' + wisdom + '"')
message = famous_person + 'once said,"' + wisdom + '"'
print(message)2-7:uname = " \t\n Hu Dalao \t"
print(uname)
print(uname.lstrip())
print(uname.rstrip())
print(uname.strip())2-8:import math
print(2+6)
print(10-2)
print(2*4)
print(math.floor(16/2))2-9:favorite_num = 12
print("my favorite number is: " + str(favorite_num))2-10:# -*- coding: utf-8 -*-
"""
Created on Sat Mar 10 21:49:18 2018
@author: huangdr
this program is homework
"""
message = "helloworld"
print(message)
message = "hello python"
print(message)2-11:>>>import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
print(message)
message = "hello python"
print(message)2-3/2-4:user_name = "Galileo Galilei"
print('"Hello ' + user_name + ", would you like to learn\
some Python today?" + '"')
print(user_name.lower())
print(user_name.upper())
print(user_name.title())2-5/2-6:famous_person = "Galileo Galilei"
wisdom = "Life is like the anvil, the more to be beat, the more able to spark."
print(famous_person + 'once said,"' + wisdom + '"')
message = famous_person + 'once said,"' + wisdom + '"'
print(message)2-7:uname = " \t\n Hu Dalao \t"
print(uname)
print(uname.lstrip())
print(uname.rstrip())
print(uname.strip())2-8:import math
print(2+6)
print(10-2)
print(2*4)
print(math.floor(16/2))2-9:favorite_num = 12
print("my favorite number is: " + str(favorite_num))2-10:# -*- coding: utf-8 -*-
"""
Created on Sat Mar 10 21:49:18 2018
@author: huangdr
this program is homework
"""
message = "helloworld"
print(message)
message = "hello python"
print(message)2-11:>>>import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
相关文章推荐
- 《Python编程 从入门到实践》第二章课后习题
- 《Python编程-从入门到实践》课后习题(5)
- 《Python编程:从入门到实践》课后练习6-1到6-11
- 《Python编程 从入门到实践》第七章课后习题
- python编程:从入门到实践课后作业(二)
- 《Python编程 从入门到实践》第十章课后习题
- 《Python编程——从入门到实践》第二章习题解
- python编程:从入门到实践-第二章练习
- 《Python编程 从入门到实践》第二章习题选做
- Python编程:从入门到实践(课后习题9)
- 《Python编程-从入门到实践》课后习题(3)
- python编程:从入门到实践 第六章课后题
- 《Python编程 从入门到实践》第九章课后习题
- Python编程:从入门到实践,课后题15-7
- python编程从入门到实践第二章习题答案
- Python编程:从入门到实践(课后习题11)
- 《Python编程:从入门到实践》课后练习3-1到3-11
- 《Python编程-从入门到实践》课后习题(4)
- Python编程:从入门到实践,课后题15-9
- Python编程:从入门到实践(课后习题10)