第24个python程序:更多练习
来源:互联网 发布:淘宝是马云还是日本人 编辑:程序博客网 时间:2024/05/17 23:44
[root@mysql1 pshell]# cat ex24.py
#!/usr/bin/env Python
#-*-coding:utf-8-*-
print "let's practice everything."
print 'you\'d need to know \'bout escapes with \\ that do \n newline and \t tabs.'
poem="""
\tthe lovely world
with logic so frimly planted
cannot discern \n the needs of love
nor comprehend passion from intuition
and requires an explanation
\n\t\twhere there is none.
"""
print "-----------------"
print poem
print "-----------------"
five=10-2+3-6
print "this should be five: %s" % five
def secret_formula(started):
jelly_beans=started*500
jars=jelly_beans/1000
crates=jars/100
return jelly_beans,jars,crates
start_point=10000
beans,jars,crates=secret_formula(start_point)
print "with a starting point of: %d" % start_point
print "we'd have %d beans,%d jars,and %d crates." % (beans,jars,crates)
start_point=start_point/10
print "we can also do that this way:"
print "we'd have %d beans,%d jars,and %d crates." % secret_formula(start_point)
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]# python ex24.py
let's practice everything.
you'd need to know 'bout escapes with \ that do
newline and tabs.
-----------------
the lovely world
with logic so frimly planted
cannot discern
the needs of love
nor comprehend passion from intuition
and requires an explanation
where there is none.
-----------------
this should be five: 5
with a starting point of: 10000
we'd have 5000000 beans,5000 jars,and 50 crates.
we can also do that this way:
we'd have 500000 beans,500 jars,and 5 crates.
#!/usr/bin/env Python
#-*-coding:utf-8-*-
print "let's practice everything."
print 'you\'d need to know \'bout escapes with \\ that do \n newline and \t tabs.'
poem="""
\tthe lovely world
with logic so frimly planted
cannot discern \n the needs of love
nor comprehend passion from intuition
and requires an explanation
\n\t\twhere there is none.
"""
print "-----------------"
print poem
print "-----------------"
five=10-2+3-6
print "this should be five: %s" % five
def secret_formula(started):
jelly_beans=started*500
jars=jelly_beans/1000
crates=jars/100
return jelly_beans,jars,crates
start_point=10000
beans,jars,crates=secret_formula(start_point)
print "with a starting point of: %d" % start_point
print "we'd have %d beans,%d jars,and %d crates." % (beans,jars,crates)
start_point=start_point/10
print "we can also do that this way:"
print "we'd have %d beans,%d jars,and %d crates." % secret_formula(start_point)
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]#
[root@mysql1 pshell]# python ex24.py
let's practice everything.
you'd need to know 'bout escapes with \ that do
newline and tabs.
-----------------
the lovely world
with logic so frimly planted
cannot discern
the needs of love
nor comprehend passion from intuition
and requires an explanation
where there is none.
-----------------
this should be five: 5
with a starting point of: 10000
we'd have 5000000 beans,5000 jars,and 50 crates.
we can also do that this way:
we'd have 500000 beans,500 jars,and 5 crates.
0 0
- 第24个python程序:更多练习
- 第7个python程序:更多打印
- 第28个python程序:布尔表达式练习
- 第25个python程序
- Learn Python The Hard Way学习(24) - 更多的练习
- 笨方法学Python 习题 24: 更多练习
- 笨方法学习Python-习题24: 更多练习
- 习题24 更多练习
- exercise 24 更多练习
- 本方法学python 习题24(综合练习) 习题25(更多关于函数和变量的练习)习题26(修改程序)
- 第1个python程序:打印
- 第2个python程序:注释#
- 第4个python程序:变量
- 第5个python程序:变量2
- 第7个python程序:打印
- 第8个python程序:还是打印
- 第10个python程序:转义
- 第11个python程序:接收输入
- Git教程
- (4.2.36.1)HTTP之OkHttp(一): Okhttp使用详解
- 关于SPCOMM使用中碰到的问题
- jquery中each循环常见问题
- 分页
- 第24个python程序:更多练习
- LintCode-拓扑排序
- 范德蒙行列式计算以应用
- 分布式架构初探-Leader Training 一期项目小分队成立了
- mongoDB 使用手册
- Http状态码之:301、302重定向
- sql 优化
- 数组应用之去除重复元素、Arrays数组工具的使用、二维数组、数组总结
- .Net 异常处理