Python Coding Interview
Python Coding Interview
Python Advanced

Use enumerate() to iterate over both indices and values
Debug problematic code with breakpoint()
Format strings effectively with f-strings
Sort lists with custom arguments
Use generators instead of list comprehensions to conserve memory
Define default values when looking up dictionary keys
Count hashable objects with the collections.Counter class
Use the standard library to get lists of permutations and combinations
enumerate()
enumerate() is a built-in function to iterate through a sequence and keep track of both the index and the number.
>>> list(range(11))
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> list(enumerate([1, 2, 3]))
[(0, 1), (1, 2), (2, 3)]
>>> list(enumerate([1, 2, 3], start=10))
[(10, 1), (11, 2), (12, 3)]
list = [45, 22, 14, 65, 97, 72].
for i, num in enumerate(numbers):
if num % 3 == 0:
numbers[i] = "fizz"
if num % 5 == 0:
numbers[i] = "buzz"
if num % 5 == 0 and num % 3 == 0:
numbers[i] = "fizzbuzz"
for i, num in enumerate(numbers):
if num % 5 == 0 and num % 3 == 0:
numbers[i] = "fizzbuzz"
elif num % 3 == 0:
numbers[i] = "fizz"
elif num % 5 == 0:
numbers[i] = "buzz"
Jupyter
Jupyter Notebook Interface
https://ipython.org/index.html
Jupyter Notebook
https://jupyter.readthedocs.io/en/latest/install.html
refs
https://realpython.com/lessons/python-coding-interview-tips-overview/
https://realpython.com/courses/python-range-function/
https://realpython.com/lessons/use-enumerate-keep-running-index/
xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
Python Coding Interview的更多相关文章
- Cracking the coding interview目录及资料收集
前言 <Cracking the coding interview>是一本被许多人极力推荐的程序员面试书籍, 详情可见:http://www.careercup.com/book. 第六版 ...
- Cracking the coding interview
写在开头 最近忙于论文的开题等工作,还有阿里的实习笔试,被虐的还行,说还行是因为自己的水平或者说是自己准备的还没有达到他们所需要人才的水平,所以就想找一本面试的书<Cracking the co ...
- 转:Top 10 Algorithms for Coding Interview
The following are top 10 algorithms related concepts in coding interview. I will try to illustrate t ...
- Cracking the coding interview 第一章问题及解答
Cracking the coding interview 第一章问题及解答 不管是不是要挪地方,面试题具有很好的联系代码总用,参加新工作的半年里,做的大多是探索性的工作,反而代码写得少了,不高兴,最 ...
- Cracking the Coding Interview(Trees and Graphs)
Cracking the Coding Interview(Trees and Graphs) 树和图的训练平时相对很少,还是要加强训练一些树和图的基础算法.自己对树节点的设计应该不是很合理,多多少少 ...
- Cracking the Coding Interview(Stacks and Queues)
Cracking the Coding Interview(Stacks and Queues) 1.Describe how you could use a single array to impl ...
- crack the coding interview
crack the coding interview answer c++ 1.1 #ifndef __Question_1_1_h__ #define __Question_1_1_h__ #i ...
- 《Cracking the Coding Interview》读书笔记
<Cracking the Coding Interview>是适合硅谷技术面试的一本面试指南,因为题目分类清晰,风格比较靠谱,所以广受推崇. 以下是我的读书笔记,基本都是每章的课后习题解 ...
- python coding style guide 的高速落地实践
python coding style guide 的高速落地实践 机器和人各有所长,如coding style检查这样的可自己主动化的工作理应交给机器去完毕,故发此文帮助你在几分钟内实现coding ...
随机推荐
- Bitter.Core系列六:Bitter ORM NETCORE ORM 全网最粗暴简单易用高性能的 NETCore ORM 之 示例 DataTable 模型转换
当我们查询之前,我们先构造一个查询对象的输出DTO.如下图代码: public class TScoreSearchDto { /// <summary> /// 分数 /// </ ...
- 为什么从REST转向gRPC 需要流式传输搜索结果,也就是在有第一批结果时就开始传输
https://mp.weixin.qq.com/s/aEO3Y8SkObNgfQU3z8sH2w 我们为什么从REST转向gRPC 原创 Levin Fritz InfoQ 2019-06-23 作 ...
- 我们都可以把它放 Sidecar 容器中,这样微服务具备了 Super power,一种超能力
云原生时代,微服务如何演进? 原创 李响 阿里技术 2020-08-28 https://mp.weixin.qq.com/s/KQG2U8_aotDL4YFB8ee6Zw 一 微服务架构与云原 ...
- DevOps运动的缘起 将DevOps想象为一种编程语言里面的一个接口,而SRE类实现了这个接口
SRE vs DevOps:是敌是友? - DockOne.io http://www.dockone.io/article/5935 RE vs DevOps:是敌是友? [编者的话]网站可靠 ...
- Building a Robust Live Reloader with WebSockets and Go — Brandur Leach https://brandur.org/live-reload
Building a Robust Live Reloader with WebSockets and Go - Brandur Leach https://brandur.org/live-relo ...
- 【LinuxShell】cp 用法详解
Linux cp命令主要用于复制文件或目录. -a:此选项通常在复制目录时使用,它保留链接.文件属性,并复制目录下的所有内容.其作用等于dpR参数组合. -d:复制时保留链接.这里所说的链接相当于Wi ...
- pthon之变量
1.变量由三部分组成: 变量名 = 值 如:name = 'xiaohan' sex='男' age = 20 2.变量名的规范 2.1 变量名只能是字母,数字或下划线的任意组合 2 ...
- Map转换为格式化的YAML字符串
yaml与java对象的互转 yaml与java对象的互转有snakeyaml <dependency> <groupId>org.yaml</groupId> & ...
- Spring(IOC、AOP和事务)
目录 Spring介绍 Spring IOC 传统代码对象管理的弊端 实现过程 bean标签属性介绍 对象创建方式 工厂bean bean的作用域 SpringBean的生命周期*** 依赖注入 注解 ...
- Linux 下mv和cp命令
注意事项:mv与cp的结果不同,mv好像文件"搬家",文件个数并未增加.而cp对文件进行复制,文件个数增加了. 一.cp命令 cp命令用来将一个或多个源文件或者目录复制到指定的目的 ...