python
燕儿哥python
匠心独具
展开
-
python基础:笔记
linux的使用/操作系统/基本的计算机知识 虚拟机 终端 文件管理器 浏览器进制的转换2 8 10 16在终端当中,用shell命令完成里linux系统的使用常用shell命令ls 查看文件夹下的内容 命令 选项-l -a .开头 . .. 路径-参数绝对路径 相对路径man q退出cd 进入到某个路径当中cd 直接回到主目录,家目录 操作系统的用户,提供默认的工作目...原创 2018-05-02 17:50:53 · 109 阅读 · 0 评论 -
python错误提示:AttributeError: 'NoneType' object has no attribute 'append'
写python程序时遇到的错误提示: AttributeError: 'NoneType' object has no attribute 'append'例如你定义了空list,想讲元素加进去l=[]m=''.join.s[i:i+k]l = l.append(m)请注意:l = l.append(m) 是不对的,【与之区分的是常用的a+=1】l.a...原创 2018-04-28 15:45:51 · 36948 阅读 · 5 评论 -
python算法:Consecutive strings
You are given an array strarr of strings and an integer k. Your task is to return the first longest string consisting of k consecutive strings taken in the array.#Example: longest_consec(["zone", "abi...原创 2018-04-28 17:47:32 · 554 阅读 · 0 评论 -
python算法:Find the divisors!
Create a function named divisors/Divisors that takes an integer and returns an array with all of the integer's divisors(except for 1 and the number itself). If the number is prime return the string '(...原创 2018-04-28 18:12:49 · 492 阅读 · 0 评论 -
python算法:Beginner Series #3 Sum of Numbers
Given two integers a and b, which can be positive or negative, find the sum of all the numbers between including them too and return it. If the two numbers are equal return a or b.Note: a and b are no...原创 2018-04-28 20:42:37 · 617 阅读 · 0 评论 -
python 算法:Descending Order
Your task is to make a function that can take any non-negative integer as a argument and return it with its digits in descending order. Essentially, rearrange the digits to create the highest possible...原创 2018-04-28 22:21:39 · 1696 阅读 · 0 评论 -
python算法:Convert string to camel case
Complete the method/function so that it converts dash/underscore delimited words into camel casing. The first word within the output should be capitalized only if the original word was capitalized.Exa...原创 2018-04-29 21:54:53 · 1032 阅读 · 0 评论 -
python 算法:Reverse words
刷到现在的感受是:不会的命令一定及时Google哈哈哈哈哈Write a reverseWords function that accepts a string a parameter, and reverses each word in the string. Any spaces in the string should be retained.Example:reverse_words("T...原创 2018-04-29 22:12:20 · 2480 阅读 · 0 评论 -
一道python面试题:不用sort()对list实现排序
这题偶然看到的,典型啊,值得马克一记!list=[2,3,5,4,9,6,8,7,1],从小到大排序,不许用sort,输出[1,2,3,4,5,6,,7,8,9]结题思路: 利用min()方法求出最小值,原列表删除最小值,新列表加入最小值,递归调用获取最小值的函数,反复操作list=[2,3,5,4,9,6,8,7,1]ll=[]if len(list)>0: m=min(...原创 2018-04-29 22:45:51 · 6873 阅读 · 5 评论 -
python 算法:罗马数字转化
class Solution: def romanToInt(self, s): """ :type s: str :rtype: int """ d={'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000} sum=0 for i...原创 2018-05-14 20:05:06 · 607 阅读 · 0 评论 -
python算法:最长公共前缀
class Solution: def longestCommonPrefix(self, strs): """ :type strs: List[str] :rtype: str """ if len(strs)==0: return '' x=0 y=...原创 2018-05-14 20:37:45 · 412 阅读 · 0 评论 -
python算法:Buying a car
A man has a rather old car being worth $2000. He saw a secondhand car being worth $8000. He wants to keep his old car until he can buy the secondhand one.He thinks he can save $1000 each month but the...原创 2018-05-12 14:19:33 · 202 阅读 · 0 评论 -
python算法:Dubstep
Polycarpus works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them.Le...原创 2018-05-12 11:42:47 · 675 阅读 · 0 评论 -
python算法:Equal Sides Of An Array
You are going to be given an array of integers. Your job is to take that array and find an index N where the sum of the integers to the left of N is equal to the sum of the integers to the right of N....原创 2018-05-12 11:21:38 · 593 阅读 · 1 评论 -
python算法:Longest Common Subsequence
Write a function called LCS that accepts two sequences and returns the longest subsequence common to the passed in sequences.SubsequenceA subsequence is different from a substring. The terms of a subs...原创 2018-05-09 15:50:38 · 913 阅读 · 0 评论 -
python算法:ROT13
How can you tell an extrovert from an introvert at NSA? Va gur ryringbef, gur rkgebireg ybbxf ng gur BGURE thl'f fubrf.I found this joke on USENET, but the punchline is scrambled. Maybe you can deciph...原创 2018-05-09 20:12:14 · 3092 阅读 · 0 评论 -
python算法:Going to zero or to infinity?
Consider the following numbers (where n! is factorial(n)):u1 = (1 / 1!) * (1!)u2 = (1 / 2!) * (1! + 2!)u3 = (1 / 3!) * (1! + 2! + 3!)un = (1 / n!) * (1! + 2! + 3! + ... + n!)Which will win: 1 / n! or ...原创 2018-05-09 20:45:14 · 378 阅读 · 0 评论 -
python基础知识:笔记2
如何运行python程序: $python3 xxxx.py数字类型:整型 int 浮点型 float布尔型 bool复数类型 complex [便于使用在数学上]Nonetype 空值 None 是对象,真是含义是啥也没有表达式 数字和运算符 +-*/ // ** %比较运算符:>< >= <= == !=布尔运算:not and or 变量:绑定数值或绑定...原创 2018-05-03 18:14:45 · 215 阅读 · 0 评论 -
python算法:Which are in?
Given two arrays of strings a1 and a2 return a sorted array r in lexicographical order of the strings of a1 which are substrings of strings of a2.#Example 1: a1 = ["arp", "live", "strong"]a2 = ["livel...原创 2018-05-03 19:52:37 · 477 阅读 · 0 评论 -
python:笔记
while 语句语法说明 1.先执行真值表达式,判断真假 2.如果为真则执行语句块1,然后跳转到第一步 3.如果为假,则执行else的语句块2,然后结束此while语句的执行,如果没有else则直接结束 4.else子句部分可省略while注意事项: 1.要控制真值表达式来防止死循环 2.通常用真值表达式内的变量来控制循环条件 3.通常要在循环语句块内改变循环变量来控制循环的次数和变...原创 2018-05-10 20:30:38 · 1770 阅读 · 0 评论 -
python基础:笔记
字符串 str 用来记录文本信息表示方法: 在非注释中,凡是用引号扩起来的部分都是字符串 '单引号 "双引号'''三单引号"""三双引号空字符串的字面值表示方式''""''''''""""""单引号和双引号的区别: 单引号内的双引号不算结束符 双引号内的单引号不算结束符三引号字符串 三引号字符串的换行会自动转换为换行符\n 三引号内可以包含单引号和多引号用转义序列代表特殊字...原创 2018-05-04 19:16:06 · 197 阅读 · 0 评论 -
python 算法:Valid Parentheses
Write a function called that takes a string of parentheses, and determines if the order of the parentheses is valid. The function should return true if the string is valid, and false if it's invalid.E...原创 2018-05-04 20:13:16 · 479 阅读 · 0 评论 -
python 算法:Product of consecutive Fib numbers
The Fibonacci numbers are the numbers in the following integer sequence (Fn):0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, ...such as:F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1.Given a num...原创 2018-05-05 10:22:31 · 588 阅读 · 0 评论 -
python算法:Palindrome chain length
Number is a palindrome if it is equal to the number with digits in reversed order. For example, 5, 44, 171, 4884 are palindromes and 43, 194, 4773 are not palindromes.Write a method palindrome_chain_l...原创 2018-05-11 20:20:06 · 400 阅读 · 0 评论 -
pygame 透明颜色 颜色透明度问题 color alpha数值 绘制透明图形
你是不是发现你的颜色给了第四个数值但绘制不起作用,颜色的透明度那里没用??别着急,哥帮你解决。一般的绘制图形和窗口填充颜色是没办法把透明度alpha的数值用起来的。需要再来一个表面,使用convert_alpha()这个函数。下面是我的一个实际例子,大家自己体会一下用法吧。图片啥的无所谓,自己随表搞几个用上就能看到效果了。import pygameimpor...原创 2019-08-10 12:03:13 · 9849 阅读 · 3 评论