博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python 面试题
阅读量:5286 次
发布时间:2019-06-14

本文共 2862 字,大约阅读时间需要 9 分钟。

 

 

python源码

https://github.com/python/cpython

【TOP50 Questions】

https://www.edureka.co/blog/interview-questions/python-interview-questions/

Q1. What is the difference between list and tuples?

LIST vs TUPLES

LIST TUPLES
Lists are mutable i.e they can be edited. Tuples are immutable (tuples are lists which can’t be edited).
Lists are slower than tuples. Tuples are faster than list.
Syntax: list_1 = [10, ‘Chelsea’, 20] Syntax: tup_1 = (10, ‘Chelsea’ , 20)

= Why tuple faster?

 a tuple made out of constant literals can easily be identified by the Python compiler as being one, immutable constant literal itself: so it's essentially built just once, when the compiler turns the source into bytecodes, and stashed away in the "constants table" of the relevant function or module. When those bytecodes execute, they just need to recover the pre-built constant tuple -- hey presto!-)

This easy optimization cannot be applied to lists, because a list is a mutable object, so it's crucial that, if the same expression such as [1, 2, 3] executes twice (in a loop -- the timeit module makes the loop on your behalf;-), a fresh new list object is constructed anew each time -- and that construction (like the construction of a tuple when the compiler cannot trivially identify it as a compile-time constant and immutable object) does take a little while.

Q2. What are the key features of Python?

  • Python is an interpreted language. That means that, unlike languages like C and its variants, Python does not need to be compiled before it is run. Other interpreted languages include PHP and Ruby.
  • Python is dynamically typed, this means that you don’t need to state the types of variables when you declare them or anything like that. You can do things like x=111 and then x="I'm a string" without error
  • Python is well suited to object orientated programming in that it allows the definition of classes along with composition and inheritance. Python does not have access specifiers (like C++’s publicprivate), the justification for this point is given as “we are all adults here”
  • In Python, functions are first-class objects. This means that they can be assigned to variables, returned from other functions and passed into functions. Classes are also first class objects
  • Writing Python code is quick but running it is often slower than compiled languages. Fortunately,Python allows the inclusion of C based extensions so bottlenecks can be optimized away and often are. The numpypackage is a good example of this, it’s really quite quick because a lot of the number crunching it does isn’t actually done by Python
  • Python finds use in many spheres – web applications, automation, scientific modelling, big data applications and many more. It’s also often used as “glue” code to get other languages and components to play nice.

  

 

 

 

转载于:https://www.cnblogs.com/ktmtwm/p/10451629.html

你可能感兴趣的文章
HTTP协议学习笔记
查看>>
sublime 打开命令窗口监控
查看>>
2014-9-4 技术创业分享汇
查看>>
利用上载漏洞,攻击asp.net 网站
查看>>
关于判断时间是今天或者昨天
查看>>
SpringMVC_HelloWorld_01
查看>>
hdu3613Best Reward
查看>>
PHP学习三--常用运算符和结构语句
查看>>
Python2与Python3的区别
查看>>
需要经常读的文章(长期更新)
查看>>
Line Painting
查看>>
python之类和__init__
查看>>
项目经理工作职责
查看>>
项目测试的流程
查看>>
IOS ——OC—— NSMutableDictionary的使用总结
查看>>
【古曲】流水-古琴曲
查看>>
【题解】 P2763 试题库问题(网络流)
查看>>
Struts2 (一)入门
查看>>
作业四: 结对编程项目---四则运算
查看>>
Windbg 驱动加载时进入调试
查看>>