PythonTip&Py学习
TriAzure
靡不有初,鲜克有终。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
PyTask 17 公约数的个数
暴力也行。 新知识点:两个数公约数的个数等于他们最大约数的约数的个数。 cnt = 1 while b: a,b = b,a%b for i in range(1, a): if (a % i == 0): cnt += 1 print(cnt) ...原创 2020-03-15 00:35:17 · 188 阅读 · 0 评论 -
PyTip Task16 人民币金额转换 |模拟 |超多细节
最近做的题里A的最感动的一道……我要哭了。 对0的处理,切成两半后连接点处的0,还有连续0的处理。 负数! 编码! # a = '9999999' m = str(a) totalans = '' if(m[0] == '-'): m = m[1:] totalans += u'负' p = len(m) dict1 = {'0':u'零','1':u'壹'...原创 2020-03-14 00:53:12 · 336 阅读 · 0 评论 -
PyTip Task15 | 大小写转换
给定一个字符串a, 将a中的大写字母 转换成小写,其它字符不变,并输出。例如:a="aaaaaabbbDDDDD"则输出:aaaaaabbbddddd 方法一:内置函数 print(a.lower()) 方法二:手动 补充ord()函数:The ord() method returns an integer representing Unicode code point for the gi...原创 2020-03-13 01:35:25 · 301 阅读 · 0 评论 -
Pytip task13&task14 | python内置函数bin()进行二进制转化与py之禅
task12 The bin() function returns the binary representation of an int object as a string.It takes an integer in decimal format and converts it to binary format. The string count() method returns the ...原创 2020-03-11 22:10:02 · 167 阅读 · 0 评论 -
Pytip task11&task12 | 乘积尾0与最后一个非零数字的奇偶性
Task11 def getzeronum(L): num2 = 0 num5 = 0 for num in L: while num%2 == 0: num/=2 num2+=1 while num%5 == 0: num/=5 num5+=1...原创 2020-03-10 22:23:16 · 163 阅读 · 0 评论
分享