日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

Python Interview Question and Answers

發布時間:2023/12/10 python 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Python Interview Question and Answers 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

引文:http://ilian.i-n-i.org/python-interview-question-and-answers/

For the last few weeks I have been interviewing several people for Python/Django developers so I thought that it might be helpful to show the questions I am asking together with the answers. The reason is … OK, let me tell you a story first.
I remember when one of my university professors introduced to us his professor – the one who thought him. It was a really short visit but I still remember one if the things he said. “Ignorance is not bad, the bad thing is when you do no want to learn.”
So back to the reason – if you have at least taken care to prepare for the interview, look for a standard questions and their answers and learn them this is a good start. Answering these question may not get you the job you are applying for but learning them will give you some valuable knowledge about Python.
This post will include the questions that are Python specific and I’ll post the Django question separately.

  • How are arguments passed – by reference of by value?
    The short answer is “neither”, actually it is called “call by object” or “call by sharing”(you can check?here?for more info). The longer one starts with the fact that this terminology is probably not the best one to describe how Python works. In Python everything is an object and all variables hold references to objects. The values of these references are to the functions. As result you can not change the value of the reference but you can modify the object if it is mutable. Remember numbers, strings and tuples are immutable, list and dicts are mutable.  May be more clear answer will be something like this (there is no short answer): Python works differently compared to other languages and there is no such a thing like passing an argument by reference or by value. If we want to compare it it will be closer to passing by reference because the object is not copied into memory instead a new name is assigned to it. I say closer and this does not mean exact because in other languages where you can pass an argument by reference, you can modify the value. In Python you also have the ability to modify the passed object but only if it is mutable type (like lists, dicts, sets, etc.). If the type of the passed object is string or int or tuple or some other kind of immutable type you can not modify it in the function.?
  • Do you know what list and dict comprehensions are? Can you give an example?
    List/Dict comprehensions are syntax constructions to ease the creation of a list/dict based on existing iterable. According to the 3rd edition of “Learning Python” list comprehensions are generally faster than normal loops but this is something that may change between releases. Examples: # simple iteration a = [] for x in range(10):a.append(x*2) # a == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]# list comprehension a = [x*2 for x in range(10)]# dict comprehension a = {x: x*2 for x in range(10)} # a == {0: 0, 1: 2, 2: 4, 3: 6, 4: 8, 5: 10, 6: 12, 7: 14, 8: 16, 9: 18}

    ?

  • What is PEP 8?
    PEP 8 is a coding convention(a set of recommendations) how to write your Python code in order to make it more readable and useful for those after you. For more information check?PEP 8.
  • Do you use virtual environments?
    I personally and most(by my observation) of the Python developers find the?virtual environment?tool extremely useful. Yeah, probably you can live without it but this will make the work and support of multiple projects that requires different package versions a living hell.
  • Can you sum all of the elements in the list, how about to multuply them and get the result? # the basic way s = 0 for x in range(10):s += x# the right way s = sum(range(10))# the basic way s = 1 for x in range(1, 10):s = s * x# the other way from operator import mul reduce(mul, range(1, 10))

    As for the last example, I know Guido van Rossum is not a fan of reduce, more info?here, but still for some simple tasks reduce can come quite handy.

  • Do you know what is the difference between lists and tuples? Can you give me an example for their usage?
    First list are mutable while tuples are not, and second tuples can be hashed e.g. to be used as keys for dictionaries. As an example of their usage, tuples are used when the order of the elements in the sequence matters e.g. a geographic coordinates, “list” of points in a path or route, or set of actions that should be executed in specific order. Don’t forget that you can use them a dictionary keys. For everything else use lists.
  • Do you know the difference between range and xrange?
    Range returns a list while xrange returns a?generator?xrange object which takes the same memory no matter of the range size. In the first case you have all items already generated(this can take a lot of time and memory) while in the second you get the elements one by one e.g. only one element is generated and available per iteration. Simple example of generator usage can be find in the?problem 2 of the “homework”?for my presentation?Functions in Python

    Just doing my duty by noting that xrange is NOT a generator?

    * xrange can be indexed (generators cannot)
    * xrange has no next method! It is iterable but not an iterator.
    * Because of the previous item, xrange objects can be iterated over multiple times (generators cannot)

  • Tell me a few differences between Python 2.x and 3.x
    There are many answers here but for me some of the major changes in Python 3.x are: all strings are now Unicode, print is now function not a statement. There is no range, it has been replaced by xrange which is removed. All classes are new style and the division of integers now returns float.
  • What are decorators and what is their usage?
    According to Bruce Eckel’s?Introduction to Python Decorators?“Decorators allow you to inject or modify code in functions or classes”. In other words decorators allow you to wrap a function or class method call and execute some code before or after the execution of the original code. And also you can nest them e.g. to use more than one decorator for a specific function. Usage examples include – logging the calls to specific method, checking for permission(s), checking and/or modifying the arguments passed to the method etc.
  • The with statement and its usage.
    In a few words the with statement allows you to executed code before and/or after a specific set of operations. For example if you open a file for reading and parsing no matter what happens during the parsing you want to be sure that at the end the file is closed. This is normally achieved using the try… finally construction but the with statement simplifies it usin the so called “context management protocol”. To use it with your own objects you just have to define __enter__ and __exit__ methods. Some standard objects like the file object automatically support this protocol. For more information you may check?Understanding Python’s “with” statement.
  • Well I hope this will be helpful, if you have any question or suggestion feel free to comment.

    Update: Due to the lots of comments on Reddit and LinkedIn, I understood that there is some misunderstanding about the post. First, the questions I have published are not the only ones I ask, the interview also includes such related to general programming knowledge and logical thinking. Second the questions above help me get a basic understanding of your Python knowledge but they are not the only think that makes my decision. Not answering some of them does not mean that you won’t get the job, but it may show me on which parts we should to work.

    ?

    轉載于:https://www.cnblogs.com/michaely/p/3352284.html

    總結

    以上是生活随笔為你收集整理的Python Interview Question and Answers的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

    主站蜘蛛池模板: 久久密| 日韩成人在线免费观看 | 欧美人妻精品一区二区三区 | 国产精品一区二区麻豆 | 中日精品一色哟哟 | 欧美午夜精品久久久久久孕妇 | www黄色| 国产一区二区影院 | 伊人色婷婷 | 欧美a久久 | 开心激情久久 | 777精品久无码人妻蜜桃 | 天堂成人av | 天天爽av| 精品国产午夜福利在线观看 | 网站一区二区 | 日韩黄网站 | 爽插| 国产美女在线免费 | 99国产超薄肉色丝袜交足 | 女色综合 | 亚洲午夜无码av毛片久久 | 亚洲精品中文字幕乱码无线 | 免费特黄视频 | 亚洲二区在线视频 | 婷婷国产成人精品视频 | 乱老熟女一区二区三区 | 黄片毛片在线观看 | 四虎永久免费在线观看 | 波多野42部无码喷潮在线 | 一本大道东京热无码 | 亚洲 欧美 另类 综合 偷拍 | 中文字幕2021 | 午夜91 | 国产精品久久久久9999爆乳 | 久久亚洲av无码西西人体 | 久久久性视频 | 蜜臀av一区二区三区有限公司 | 国产一级视频在线观看 | 波多野结衣一区二 | 欧美性理论片在线观看片免费 | 国产黄色精品网站 | 成年人免费网站在线观看 | a级片在线 | 亚洲国产精品久久精品怡红院 | 国产一区二区三区亚洲 | 亚洲精品二区三区 | 小少妇哺乳喂奶播放 | 国产免费一区二区三区网站免费 | 奇米影视久久久 | 亚洲色成人www永久在线观看 | 91免费视频 | 波多野结衣一区在线 | 亚洲av无码乱码国产麻豆 | 日韩城人视频 | 综合精品视频 | 欧美成人视屏 | 欧美日韩亚洲色图 | 在线sese| 中文字幕有码在线观看 | 成人午夜免费电影 | 极品91尤物被啪到呻吟喷水 | 青娱乐超碰在线 | 成人在线观看亚洲 | av精选| 手机成人免费视频 | www.亚洲一区二区三区 | www.猫咪av.com | 欧美性猛交ⅹ乱大交3 | 在线观看av免费 | 亚洲天堂男人网 | 欧美午夜一区 | 日韩欧美亚洲成人 | 在线精品亚洲欧美日韩国产 | 麻豆做爰免费观看 | 欧美色图片区 | 高清不卡视频 | 99久久婷婷 | 污网站在线观看免费 | 伊人论坛 | 久久99国产精品一区 | 国产欧美日韩在线 | 在线免费观看污网站 | 99精品毛片 | 91麻豆精品一区二区三区 | 精品国产一区二区三区噜噜噜 | 精品久久电影 | 瑟瑟视频免费观看 | 精品国产亚洲一区二区麻豆 | 麻豆视 | 粉嫩av一区二区夜夜嗨 | 免费观看日韩av | 亚洲天堂欧美 | 五月激情五月婷婷 | 日本人做爰全过程 | 久久午夜场 | 十八岁世界在线观看高清免费韩剧 | 久久性色| 国产露脸国语对白在线 |