ex24.py

 1 # -*- coding:utf-8 -*-
 2 print ("Let‘s practice everything.")
 3 print (‘You\‘d need to know \‘bout escapes with \\ that do \n newlines and \t  tabs.‘)
 4
 5 ‘‘‘poem = """
 6 \tThe lovely world
 7 with logic so firmly planted
 8 cannot discern \n the needs of love
 9 nor comprehend passion from intuition
10 and requires an explanation
11 \n\t\twhere there is none.
12 """
13 ‘‘‘
14 poem = input("\n>>>>>")
15 print ("--------------")
16 print (poem)    #python3 中变量也需要打()
17 print ("--------------")
18
19
20 five = 10 - 2 + 3 - 6
21 print("This should be five: %s" % five)
22
23 def secret_formula(started):
24     jelly_beans = started * 500
25     jars = jelly_beans / 1000
26     crates = jars / 100
27     return jelly_beans, jars, crates
28
29
30 start_point = int(input("start_point?\n>>>>"))
31 beans, jars, crates = secret_formula(start_point)   #注意本行的用法
32 print ("With a starting point of: %d" % start_point)
33 print ("we‘d have %d beans, %d jars, and %d crates." % (beans,jars,crates))
34
35 start_point = start_point / 10
36
37 print("We can also do that this way:")
38
39 print("we‘d have %d beans, %d jars, and %d crates." % secret_formula(start_point))
40
41
42     
时间: 2024-10-06 21:41:55

ex24.py的相关文章

20170919习题

ex24.py #更多练习print("let's practice everything.")print("you\'d need to know \' bout escapes with \\ that do \n newlines and \t tabs.")#\转义符,\'输出为',\\输出为\,\n输出为重新开始新一行,\t输出为tabs. poem = """ \t the lovely world with logic s

使用TDD理解views.py与urls.py的关系

首先必须对MVC的概念有初步的认识,django也遵循这样一套规范,views.py相当于视图函数,是整个架构中的处理引擎,而urls.py的作用就是将用户请求送入这样的引擎. 项目结构: urls.py: from django.conf.urls import include, url from django.contrib import admin urlpatterns = [ # Examples: #url(r'^$', 'mysite.views.home', name='home

layers.py cs231n

如果有错误,欢迎指出,不胜感激. import numpy as np def affine_forward(x, w, b): 第一个最简单的 affine_forward简单的前向传递,返回 out,cache """ Computes the forward pass for an affine (fully-connected) layer. The input x has shape (N, d_1, ..., d_k) and contains a minibat

Python pydoc.py

1. 查看帮助,我们可以在python命令行交互环境下用 help函数,比如: 查看 math 模块: >>> help('math')Help on built-in module math: NAME math DESCRIPTION This module is always available. It provides access to the mathematical functions defined by the C standard. FUNCTIONS acos(..

创建py模板

创建模板之后,每次新建py文件,已初始定义的代码段将会自动出现在py文件中.

python下编译py成pyc和pyo

其实很简单,用python -m py_compile file.py python -m py_compile /root/src/{file1,file2}.py编译成pyc文件.也可以写份脚本来做这事:Code: import py_compile py_compile.compile('path') //path是包括.py文件名的路径 用python -O -m py_compile file.py 编译成pyo文件.1.其中的 -m 相当于脚本中的import,这里的-m py_co

django 运行python manage.py sqlall books 时报错 app has migration

出现这个问题的原因是版本之前的不兼容,我用的django版本是1.8.6 而 这条python manage.py sqlall books 是基于django1.0版本的. 在django1.8.6版本中生成一个表的语句是    $ python manage.py makemigrations books $ python manage.py sqlmigrate books 0001 django book2 是一本不错的教程,但是就是版本太老了,可以通过看book2对django有一个比

word2vec_basic.py

ssh://[email protected]:22/usr/bin/python3 -u /home/win_pymine_clean/feature_wifi/word2vec_basic.py Found and verified text8.zip Data size 17005207 Most common words (+UNK) [['UNK', 418391], ('the', 1061396), ('of', 593677), ('and', 416629), ('one',

如何在Windows下用cpu模式跑通py-faster-rcnn 的demo.py

关键字:Windows.cpu模式.Python.faster-rcnn.demo.py 声明:本篇blog暂时未经二次实践验证,主要以本人第一次配置过程的经验写成.计划在7月底回家去电脑城借台机子试试验证步骤的正确性,本blog将根据实际遇到的问题持续更新.另外blog中除提到的下载链接外我还会给出网盘链接方便下载,包括我的整个工程的网盘链接.如果有些报错解决不了可直接拿本人的相关文件替换,本篇blog具有较高的参考性. 本人微软版caffe工程     下载链接:http://pan.bai