100 basic Python interview questions Part II (41-60)

Hai Yong* 2021-10-28 18:54:12
basic python interview questions ii

Author URI : Hai Yong
Author's brief introduction :CSDN High quality creators in the whole stack field 、HDZ Core group members 、 Reelection C Standing in the top ten of the weekly list
Fan benefits : Fans group Send four books a week , Send all kinds of small gifts every month ( enamelled cup 、 Pillow 、 Mouse pad 、 Mugs, etc )

Jump straight to the end Go to the review area to get the book

100 A basic Python The second part of the interview question (21-40)

Q-1: What is? Python, What are the benefits of using it , You are right about PEP 8 What's your understanding of ?
Q-2: following Python What is the output of the code snippet ? Prove your answer .
Q-3: If the program doesn't need an action but needs it grammatically , Can be in Python What are the statements used in ?
Q-4: stay Python Use in “~” What is the process of getting the home directory ?
Q-5:Python What are the built-in types available in ?
Q-6: How to be in Python Find errors in the application or perform static analysis ?
Q-7: When to use Python Decorator ?
Q-8: What is the main difference between lists and tuples ?
Q-9:Python How to handle memory management ?
Q-10:lambda and def What is the main difference between ?
Q-11: Use python reg Expression module “re” Write a reg Expression to validate the e-mail ID?
Q-12: What do you think is the output of the following code snippet ? Are there any errors in the code ?
Q-13:Python There is switch or case Statement ? If not , So what is the same reason ?
Q-14:Python What is the built-in function used to iterate over a sequence of numbers ?
Q-15:Python Of try-except What optional statements might be in the block ?
Q-16:Python What is the string in ?
Q-17:Python What is the slice in ?
Q-18:Python Medium %s What is it? ?
Q-19: The string is in Python Is it immutable or variable ?
Q-20:Python What is the index in ?
Q-21:Python What is the document string in ?
Q-22:Python What are the functions in programming ?
Q-23:Python How many basic types of functions are there in ?
Q-24: How do we use Python Write function ?
Q-25:Python What are the function calls or callable objects in ?
Q-26:Python Medium return What are keywords used for ?
Q-27:Python Medium “ Call... By value ” What is it? ?
Q-28:Python Medium “ Call... By reference ” What is it? ?
Q-29:trunc() What is the return value of the function ?
Q-30:Python Must the function return a value ?
Q-31:Python Medium continue What's the role ?
Q-32:Python in id() What is the purpose of the function ?
Q-33:*args stay Python What's in it ?
Q-34:**kwargs stay Python What to do in ?
Q-35:Python Yes Main() Methods? ?
Q-36: __ Name __ stay Python What's in it ?
Q-37:Python in “end” What is the purpose ?
Q-38: When should it be in Python Use in “break”?
Q-39:Python Medium pass and continue What's the difference? ?
Q-40:len() Function in Python What's in it ?
Q-41:chr() Function in Python What's in it ?
Q-42:ord() Function in Python What's in it ?
Q-43:Python Medium Rstrip() What is it? ?
Q-44:Python What is the space in ?
Q-45:Python Medium isalpha() What is it? ?
Q-46: How do you Python Use in split() function ?
Q-47:Python Medium join What is the effect of methods ?
Q-48:Title() Method in Python What's in it ?
Q-49: What makes CPython And Python Different ?
Q-50: Which bag is the fastest Python form ?
Q-51:Python In language GIL What is it? ?
Q-52:Python How to achieve thread safety ?
Q-53:Python How to manage memory ?
Q-54:Python What are the tuples in ?
Q-55:Python What is the dictionary in programming ?
Q-56:Python Medium set What is the object ?
Q-57: The dictionary is Python What's the use of ?
Q-58:Python Is the list a linked list ?
Q-59:Python Medium Class What is it? ?
Q-60:Python What are the properties and methods in the class ?
Jump straight to the end Go to the review area to get the book


Q-41: chr() Function in Python What's in it ?

chr() Function in Python 3.2 Re add . stay 3.0 In the version , It was deleted .

It returns a representation of Unicode A string of characters whose code point is an integer .

for example ,chr(122) Return string ‘z’ and chr(1212) Return string ‘Ҽ’.

Back to directory


Q-42:ord() Function in Python What's in it ?

Python Medium ord(char) Accept a size of 1 String , If it is Unicode Type object , Returns a... Representing the character Unicode Integer in code format , Or if the parameter is 8 Bit string type , Returns the value of bytes .

>>> ord("z")
122

Back to directory


Q-43:Python Medium Rstrip() What is it? ?

Python Provides rstrip() Method , This method can copy the string, but omit the white space character from the end .

rstrip() Escape the character... From the right end according to the parameter value , It's a string , Mention the character group to exclude .

rstrip() His signature is :

str.rstrip([char sequence/pre>
test_str = 'Programming '
# Trailing spaces are excluded 
print(test_str.rstrip())

Back to directory


Q-44:Python What is the space in ?

Spaces represent the characters we use for spacing and separation .

They have “ empty ” Express . stay Python in , It can be a tab or a space .

Back to directory


Q-45:Python Medium isalpha() What is it? ?

Python Provides this built-in isalpha() Function to handle string .

If all characters in the string are alphabetic , Then return to True, Otherwise return to False.

Back to directory


Q-46: How do you Python Use in split() function ?

Python Of split() The function handles strings , Cut a large piece into smaller pieces or substrings . We can specify a separator to start splitting , Or it defaults to using spaces as a .

str = 'pdf csv json'
print(str.split(" "))
print(str.split())

Output :

['pdf', 'csv', 'json']
['pdf', 'csv', 'json']

Back to directory


Q-47:Python Medium join What is the effect of methods ?

Python Provided for string 、 Lists and tuples join() Method . It combines them and returns a uniform value .

Back to directory


Q-48:Title() Method in Python What's in it ?

Python Provides title() Method converts the first letter of each word to uppercase , The rest are converted to lowercase .

str = 'lEaRn pYtHoN'
print(str.title())

Output :

Learn Python

Now? , Check out some general Python Interview questions .

Back to directory


Q-49: What makes CPython And Python Different ?

CPython The core of the idea is to use C Developed . Prefix “C” Represents this fact . It runs an interpreter loop , Is used to Python-ish Code translation into C Language .

Back to directory


Q-50: Which bag is the fastest Python form ?

PyPy Provide maximum compatibility , Simultaneous utilization CPython Implementation to improve its performance .

Test confirmation PyPy Than CPython Nearly five times faster . It currently supports Python 2.7.

Back to directory


Q-51:Python In language GIL What is it? ?

Python Support GIL( Global interpreter lock ), It's a mutex , Used to protect against Python Object access , Synchronize multiple threads running simultaneously Python Bytecode .

Back to directory


Q-52:Python How to achieve thread safety ?

Python Ensure secure access to threads . It USES GIL Mutex to set synchronization . If a thread is lost at any time GIL lock , Then you must make your code thread safe .

for example , many Python Operations are performed atomically , For example, call... On a list sort() Method .

Back to directory


Q-53:Python How to manage memory ?

Python A heap manager is implemented internally , It holds all its objects and data structures .

This heap manager allocates... To objects / Deallocate heap space .

Back to directory


Q-54:Python What are the tuples in ?

A tuple is Python Immutable collection type data structure in .

They are similar to sequences , Like a list . however , There are some differences between tuples and lists ; The former cannot be modified , And the list allows .

Besides , Tuples are enclosed in parentheses , But there are square brackets in the syntax of the list .

Back to directory


Q-55:Python What is the dictionary in programming ?

A dictionary is a data structure , stay Python Is called associative array , A collection used to store objects .

The collection is a set of keys with a single associated value . We can call it hash 、 Mapping or hash mapping , Because it is called in other programming languages .

Back to directory


Q-56:Python Medium set What is the object ?

A set is Python Unordered collection objects in . They store unique and immutable objects .Python The implementation of comes from mathematics .

Back to directory


Q-57: The dictionary is Python What's the use of ?

A dictionary has a set of objects ( key ) Map to another set of objects ( value ).Python A dictionary represents a unique key to value mapping .

They are variable , So it won't change . The value associated with the key can be any Python type .

Back to directory


Q-58:Python Is the list a linked list ?

Python The list is a variable length array , It is different from C The style of the chain .

In the internal , It has a contiguous array that references other objects , And store pointers to array variables and their lengths in the list header structure .

Here are some about classes and objects Python Interview questions .

Back to directory


Q-59:Python Medium Class What is it? ?

Python Support for object-oriented programming , And provides almost all OOP Features for program use .

Python Classes are blueprints for creating objects . It defines member variables and gets the behavior associated with them .

We can use keywords “class” To achieve . Objects are created from constructors . This object represents an instance of the class .

stay Python in , We generate classes and instances in the following ways .

>>>class Human:
... pass
>>>man = Human()
>>>print(man)
<__main__.Human object at 0x0000000003559E10>

Back to directory


Q-60:Python What are the properties and methods in the class ?

If a class does not define any functions , It's useless . We can do this by adding properties . They serve as containers for data and functions . We can add an attribute directly to the class body .

>>> class Human:
... profession = "programmer"
>>> man = Human()
>>> print(man.profession)
programmer

After adding properties , We can continue to define functions . Usually , We call them methods . In the method signature , We always have to provide a for the first parameter self keyword .

>>> class Human:
profession = "programmer"
def set_profession(self, new_profession):
self.profession = new_profession
>>> man = Human()
>>> man.set_profession("Manager")
>>> print(man.profession)
Manager

Back to directory


Draw fans and send books in the comment area

You are welcome to put forward your opinions and suggestions in the comment area !( Pick two lucky people to send books , The physical drawing is as follows )

 Insert picture description here

《Python Web Development from entry to mastery 》

【 Content abstract 】

(1) Case teaching . This book contains a lot of sample code , The examples are concise and to the point , Readers only need to refer to the source code , Modification example , You can get what you want , It really makes readers understand 、 Learn to be able to 、 I can do it .
(2) The system is comprehensive . Comprehensive explanation Python Basics 、 Database foundation 、 Front end Foundation 、Python Web Popular frame 、 actual combat 、 Operation and maintenance deployment, etc . because Python Web Not limited to one framework , So this book explains the current popular 4 A frame , So that readers in the development work can achieve mastery .
(3) Personal training . The whole book is arranged 12 individual “ Practical drill ”, All are the summary of the author's practical development experience for many years . adopt “ Practical drill ” Practical training , Readers can consolidate their knowledge as soon as possible , To draw inferences from one case .
(4) exclude the difficulty and anxiety . The whole book is arranged 26 individual “ Novice question and answer ”, Help beginners solve common problems .

There should also be students who want to buy their own , Please refer to the link below

JD self purchase link :
《Python Web Development from entry to mastery 》( Wang Haifei ) - Jingdong books
Dangdang self operated purchase link :
《Python Web Development from entry to mastery 》( Wang Haifei ) - When books

Be careful :

Everyone likes and pays attention to , Three days later 10 month 15 Japan Select two students from the comment area to send books

Industry information : The high-quality goods PPT Thousands of templates , More than 1000 resume templates
Interview question bank :Java A complete collection of core knowledge points and real interview questions
Learning materials :2300 set PHP Website source code , Introduction to wechat applet ,Python The complete (400 Set )

If you win the prize and can't get in touch, it will be regarded as giving up , You can find the author's contact form from the official account below. , Four books a week , The strength of sending books will be increased later , It's not a problem to send hundreds or thousands of copies a year , reply 【 Into the group of 】 Don't get lost when you get a book , Within group Every member I always send one . reply 【 resources 】 The above information can be obtained

版权声明
本文为[Hai Yong*]所创,转载请带上原文链接,感谢
https://pythonmana.com/2021/10/20211013025714688W.html

  1. matlab改为python,偏最小二乘回归分析的一个程序
  2. 应该是python基础题希望能用基础方法解决
  3. 想找个会Python的做场外援助,上课没听明白
  4. Python程序,插入不了MySQL的date格式
  5. (初学者)关于Python操作Excel问题
  6. 求人来解答这两道Python题
  7. python中用三引号换行,举例说明
  8. python数码管该怎么用,十四段
  9. python进行中文文本聚类(切词以及Kmeans聚类)
  10. Python - 字符串作为文件
  11. Python - 转换二进制为ASCII码
  12. Python - 在段落中计算令牌
  13. Python - 重新格式化段落
  14. Python - 排序线
  15. Python - 字符串不变性
  16. Python - 文本摘要
  17. Python+微信小程序开发(六)双向绑定和前后端通信
  18. 基于Anaconda搭建Django环境
  19. Django基础篇(2)--视图
  20. 288页的python编程文档,从入门到实践,入门看这一篇就够了
  21. Python Web实战:Flask + Vue 开发一个漂亮的词云网站
  22. 让我深夜十二点催她睡觉,我用 Python 轻松搞定!
  23. 4.Python-常用语句
  24. 【Python】基于FastAPI的Restful规范实践
  25. 【Python】FastAPI脚手架:规范FastAPI后端接口项目开发
  26. 【Python】单元测试实践内部指南
  27. Django开发中使用Cache缓存提升10倍效率
  28. python如何重复执行程序命令而不是一次退出
  29. python 编写程序题使用for循环
  30. 一道简单的python作业题,就是不能运行
  31. 使用python回答,望有人来帮
  32. 用python插入日期格式到mysql数据库中,一直运行不了。
  33. 关于以下Python问题如何解决
  34. Use Python to help the financial sister solve the PDF splitting. The sister said it was great...
  35. Comment résoudre les problèmes Python suivants
  36. 如何使用python建立列表?新手入门
  37. python 3d画图库matplotlib,第一次用
  38. python 3d畫圖庫matplotlib,第一次用
  39. Python 3D painting Library matplotlib, utilisé pour la première fois
  40. Comment créer une liste en utilisant python? Débutant
  41. python定义列表 新手入门级别
  42. Liste de définition Python débutant
  43. 如何用Python实现,急!!xdm
  44. 如何用Python實現,急!!xdm
  45. Comment implémenter en python, urgent!! Xdm
  46. 新猿木子李:0基础学python培训教程 Python操作Redis之hash类型
  47. python导入模块变量后,打印的值固定不变了,大老们怎么破。
  48. Why is my rust slower than Python!
  49. 用Python给喜欢的女孩写一个办公小工具,她说棒极了!
  50. python中\t是空一个tab,那这个1.2后面怎么没空格?
  51. Il y a un onglet vide en python, alors pourquoi n'y a - t - il pas d'espace après ce 1.2?
  52. 关于python中pygame.display.set_mode()的一点小问题
  53. 猜我能否用Python编程抢到茅台?已经全部开源到GitHub了
  54. python数据分析numpy 补充短试题
  55. 2W + word long article, an article on literacy python, numpy and pandas, recommended collection!
  56. Python培训-自动化运维常用库
  57. On the magical usage and principle of weak reference in Python
  58. Formation python - bibliothèques d'exploitation et de maintenance automatisées
  59. Python培训-HTTP与HTTPS之间的区别
  60. Python有哪些高级特性?