列表操作list函数:[python] view plaincopy>>>list('hello')['h','e','l','l','o']改变列表:[python] view plaincopy>>>x=[1,1,1]>>>x[1]=2>>>x[1,2,1]删除元素:[python] view ...
分类:
编程语言 时间:
2014-11-13 00:27:27
阅读次数:
264
命令行运行Python脚本Linux下先创建一个hello.py[python] view plaincopy$gedithello.py输入:[python] view plaincopy#!/usr/bin/envpythonprint2+2保存退出,运行:[python] view plain...
分类:
编程语言 时间:
2014-11-13 00:17:32
阅读次数:
263
The count-and-say sequence is the sequence of integers beginning as follows:
1, 11, 21, 1211, 111221, ...
1 is read off as "one
1" or 11.
11 is read off as "two
1s" or 21.
21 is read off as ...
分类:
其他好文 时间:
2014-11-12 19:50:50
阅读次数:
164
条件与循环
条件执行:
name = raw_input('What is your name? ')
if name.endswith('Gumby'):
print 'Hello, Mr.Gumby'What is your name? Gumby
Hello, Mr.Gumbyname = raw_input('What is your name? ')
if name.endswit...
分类:
编程语言 时间:
2014-11-12 19:50:03
阅读次数:
245
$ gedit price.py
#!/usr/bin/env python
width = input('Please enter width: ')
price_width = 10
item_width = width - price_width
header_format = '%-*s%*s'
format = '%-*s%*.2f'
print '=' * width...
分类:
编程语言 时间:
2014-11-12 16:33:21
阅读次数:
248
列表操作
list函数:
>>> list('hello')
['h', 'e', 'l', 'l', 'o']改变列表:
>>> x=[1,1,1]
>>> x[1]=2
>>> x
[1, 2, 1]删除元素:
>>> names = ['wu','li','zhao','qian']
>>> del names[1]
>>> names
['wu', 'zhao', 'qian']分...
分类:
编程语言 时间:
2014-11-12 15:06:10
阅读次数:
142
数字和表达式
加减乘除:
>>> 2+2
4
>>> 100-50
50
>>> 3*5
15
>>> 1/2
0
>>> 1.0/2.0
0.5求余、乘方:
>>> 1%2
1
>>> 10%3
1
>>> 2**3
8
>>> -3**2
-9
>>> (-3)**2
9十六进制、八进制:
>>> 0xff
255
>>> 020
16变量:
>>> x=3
>>> x*2
6获取输...
分类:
编程语言 时间:
2014-11-12 13:53:31
阅读次数:
211
命令行运行Python脚本
Linux下先创建一个hello.py
$ gedit hello.py
输入:
#!/usr/bin/env python
print 2+2保存退出,运行:
$ python hello.py
4我们也可以让它变得和普通程序一样执行
执行之前,让脚本文件具备可执行属性:
$ chmod a+x hello.py运行脚本:
$ ./hello.py ...
分类:
编程语言 时间:
2014-11-12 13:47:51
阅读次数:
180
Milliard Vasya's Function
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u
Submit Status
Description
Vasya is the beginning mathematician. He decided to make an impor...
分类:
其他好文 时间:
2014-11-11 09:26:25
阅读次数:
272
The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1is read off as"one 1"or11.11is read off as"tw...
分类:
其他好文 时间:
2014-11-10 06:30:28
阅读次数:
178