π The Python Interview Handbook 2023 (2023)
1β£ Join Channel Download:
https://t.me/+MhmkscCzIYQ2MmM8
2β£ Download Book: https://t.me/c/1854405158/671
π¬ Tags: #python #Interview
USEFUL CHANNELS FOR YOU
1β£ Join Channel Download:
https://t.me/+MhmkscCzIYQ2MmM8
2β£ Download Book: https://t.me/c/1854405158/671
π¬ Tags: #python #Interview
USEFUL CHANNELS FOR YOU
π31
π CRACKING the CODING INTERVIEW (2023)
1β£ Join Channel Download:
https://t.me/+MhmkscCzIYQ2MmM8
2β£ Download Book: https://t.me/c/1854405158/673
π¬ Tags: #INTERVIEW
USEFUL CHANNELS FOR YOU
1β£ Join Channel Download:
https://t.me/+MhmkscCzIYQ2MmM8
2β£ Download Book: https://t.me/c/1854405158/673
π¬ Tags: #INTERVIEW
USEFUL CHANNELS FOR YOU
π32β€6
Ace the Python Coding Interview
Link: https://www.educative.io/path/ace-python-coding-interview?aff=KQEy
#python #coding #interview
π BEST DATA SCIENCE CHANNELS ON TELEGRAM π
Python is a high level, dynamically typed, and object-oriented language that is easy to read and write. It has a large, supportive community of developers that contribute to its development and support. Python's simplicity, flexibility, and versatility make it a perfect choice in the industry. This Skill Path will take you through all that you need to know to crack your Python interviews with confidence. Youβll cover everything from data structures to object-oriented design and concurrency. You will also get to know the essential patterns behind popular coding interview questions. By the time youβre done, your skills will be polished to ace the interview of any company.
Link: https://www.educative.io/path/ace-python-coding-interview?aff=KQEy
#python #coding #interview
π BEST DATA SCIENCE CHANNELS ON TELEGRAM π
π6β€2
Forwarded from PyData Careers
β Interview Question
What is the difference between
tags: #interview #python #magicmethods #classes
β‘οΈ @DataScienceQ π€
What is the difference between
__str__ and __repr__ methods in Python classes, and when would you implementstr__str__ returns a human-readable string representation of an object (e.g., via print(obj)), making it user-friendly for displayrepr__repr__ aims for a more detailed, unambiguous string that's ideally executable as code (like repr(obj)), useful for debuggingβimstr __str__ for end-user outrepr__repr__ for developer tools or str __str__ is defined.tags: #interview #python #magicmethods #classes
Please open Telegram to view this post
VIEW IN TELEGRAM
β€1
β Interview Question
What is the potential pitfall of using a mutable object (like a list or dictionary) as a default argument in a Python function?
Answer: A common pitfall is that the default argument is evaluated only once, when the function is defined, not each time it is called. If that default object is mutable, any modifications made to it in one call will persist and be visible in subsequent calls.
This can lead to unexpected and buggy behavior.
Incorrect Example (The Pitfall):
The Correct, Idiomatic Solution:
The standard practice is to use
tags: #Python #Interview #CodingInterview #PythonTips #Developer #SoftwareEngineering #TechInterview
βββββββββββββββ
By: @DataScience4 β¨
What is the potential pitfall of using a mutable object (like a list or dictionary) as a default argument in a Python function?
Answer: A common pitfall is that the default argument is evaluated only once, when the function is defined, not each time it is called. If that default object is mutable, any modifications made to it in one call will persist and be visible in subsequent calls.
This can lead to unexpected and buggy behavior.
Incorrect Example (The Pitfall):
def add_to_list(item, my_list=[]):
my_list.append(item)
return my_list
# First call seems to work fine
print(add_to_list(1)) # Output: [1]
# Second call has unexpected behavior
print(add_to_list(2)) # Output: [1, 2] -- The list from the first call was reused!
# Third call continues the trend
print(add_to_list(3)) # Output: [1, 2, 3]
The Correct, Idiomatic Solution:
The standard practice is to use
None as the default and create a new mutable object inside the function if one isn't provided.def add_to_list_safe(item, my_list=None):
if my_list is None:
my_list = [] # Create a new list for each call
my_list.append(item)
return my_list
# Each call now works independently
print(add_to_list_safe(1)) # Output: [1]
print(add_to_list_safe(2)) # Output: [2]
print(add_to_list_safe(3)) # Output: [3]
tags: #Python #Interview #CodingInterview #PythonTips #Developer #SoftwareEngineering #TechInterview
βββββββββββββββ
By: @DataScience4 β¨
β€2
β Interview question
How do you create a new directory using the
Answer:The primary function to create a new directory (and any necessary parent directories) is . To gracefully manage situations where the target directory might already exist without causing a , the recommended approach is to set the parameter to . This ensures that if the directory already exists, no exception is raised, allowing your program to continue execution smoothly. An example usage would be .
tags: #interview #os #PythonBasics #FileSystem
βββββββββββββββ
By: @DataScience4 β¨
How do you create a new directory using the
os module in Python, and what is the recommended way to handle cases where the directory might already exist?Answer:
os.makedirs()FileExistsErrorexist_okTrueos.makedirs('path/to/my/new_directory', exist_ok=True)tags: #interview #os #PythonBasics #FileSystem
βββββββββββββββ
By: @DataScience4 β¨