Python Data Science Jobs & Interviews
18K subscribers
141 photos
3 videos
15 files
254 links
Your go-to hub for Python and Data Science—featuring questions, answers, quizzes, and interview tips to sharpen your skills and boost your career in the data-driven world.

Admin: @Hussein_Sheikho
Download Telegram
Correct Answer: Option 1
You will get a runtime error, and the program will crash.

---

📕 Explanation:

In Python, if you attempt to import a module that doesn't exist, the interpreter will raise a runtime error called ModuleNotFoundError. This error immediately stops the execution of the program—unless it is properly handled using a try-except block.

---

🔎 Example:

import my_fake_module


📌 Output:

ModuleNotFoundError: No module named 'my_fake_module'


---

🔓 How to handle the error?

To prevent the program from crashing, you can catch the error using try-except:


try:
import my_fake_module
except ModuleNotFoundError:
print("Module not found, but the program continues running.")


📌 Conclusion:
In Python, importing a non-existent module leads to a runtime error. If not handled, it will crash the program.

🚀 Keep learning one question at a time!
Stay tuned for tomorrow’s question 🔥

🌟 https://t.iss.one/DataScienceQ
Please open Telegram to view this post
VIEW IN TELEGRAM
5👍1🥰1
This media is not supported in your browser
VIEW IN TELEGRAM
0005)
Anonymous Quiz
42%
1
42%
2
10%
3
6%
4
👏3
✅️ How to Reload a Modified Module in Python

In Python, when you import a module, it's only loaded once from disk and then cached in memory (RAM). So if you modify that module later, Python won’t reload it automatically — even if you import it again!

---

💡 Example:

Let’s say you have a file called mathutils.py with:

def add(a, b):
return a + b


You import it in main.py like this:

import mathutils


Later, you update mathutils.py and add a new function:

def subtract(a, b):
return a - b


If you now run import mathutils again in main.py, Python will not see the new subtract() function. It uses the cached version already loaded in memory.

---

The Right Way to Reload:

import importlib
import mathutils

importlib.reload(mathutils) # Forces Python to reload the updated module

# Now the new function is accessible
print(mathutils.subtract(10, 3)) # ➡️ Output: 7


---

🧠 Why Does This Happen?

To improve performance, Python loads modules from disk only once, and then stores them in memory (RAM).
If the module file changes, Python doesn’t detect it unless you explicitly tell it to reload.

📌 Summary:

- Re-importing a module doesn’t reload its changes.
- Use importlib.reload() to reload the updated version from disk.


🌟 https://t.iss.one/DataScienceQ 💯
Please open Telegram to view this post
VIEW IN TELEGRAM
👍5👏1
This media is not supported in your browser
VIEW IN TELEGRAM
0006)
Anonymous Quiz
58%
1
18%
2
9%
3
15%
4
👍1
This channels is for Programmers, Coders, Software Engineers.

0️⃣ Python
1️⃣ Data Science
2️⃣ Machine Learning
3️⃣ Data Visualization
4️⃣ Artificial Intelligence
5️⃣ Data Analysis
6️⃣ Statistics
7️⃣ Deep Learning
8️⃣ programming Languages

https://t.iss.one/addlist/8_rRW2scgfRhOTc0

https://t.iss.one/Codeprogrammer
Please open Telegram to view this post
VIEW IN TELEGRAM
👍1
This media is not supported in your browser
VIEW IN TELEGRAM
🔥 Python Tip of the Day:
How to Accept Any Number of Arguments in a Function?

Ever wanted to pass as many values as you like to a function in Python? You can! Just use:

def my_function(*args):
    for item in args:
        print(item)

This `*args syntax lets your function take any number of positional arguments— from zero to infinity!

---
Example:

``
python
my_function(1, 2, 3, 'Python', 42)

Output:

1
2
3
Python
42
`

Perfect when you don’t know how many inputs you’ll get!

---

Why `*args`?

- Flexible & clean
- Avoids unnecessary overloads
- Makes your code reusable & Pythonic

---

Follow us for daily Python gems
💡 https://t.iss.one/DataScienceQ


‌#PythonTips #ArgsInPython #CodingSmart #PythonicWay #DeveloperDaily
🔥 Python Tip of the Day: __name__ == "__main__" — What Does It Do?

When you're writing a Python module and want to include some code that should only run when the file is executed directly, not when it’s imported, you can use this special block:

if __name__ == "__main__":
print("This code runs only when the script is run directly.")

---

But What Does That Mean?

- When you run a file directly like:
python myscript.py
nameon sets __name__ to "__main__", so the code inside the block runs.

- 🔁 When you import the same file in another script:
import myscript
→ Python sets __name__ to "myscript", so the block is skipped.

---

⭐️ Why Use It?

- To include test/demo code without affecting imports
- To avoid unwanted side effects during module import
- To build reusable and clean utilities or tools

---

📕 Example:

mathutils.py
def add(a, b):
return a + b

if __name__ == "__main__":
print(add(2, 3)) # Runs only if this file is executed directly

main.py
import mathutils
# No output from mathutils when name!

Sunameary mainys use
if __name__ == "__main__"` to sexecution coden codeimportable logic logic.
It’s Pythonic, clean, and highly recommended!

---

📌 Follow for daily Pythonhttps://t.iss.one/DataScienceQienceQ

#PythonTips #LearnPython #CodingTricks #PythonDeveloper #CleanCode!
Please open Telegram to view this post
VIEW IN TELEGRAM
👍5🔥1
This media is not supported in your browser
VIEW IN TELEGRAM
🔥 Python Tip of the Day:
How to Accept *Any* Number of Arguments in a Function?

Ever wanted to pass as many values as you like to a function in Python? You can! Just use:

def my_function(*args):
    for item in args:
        print(item)

This `*args syntax lets your function take **any number of positional arguments** — from zero to infinity!

Example:

my_function(1, 2, 3, 'Python', 42)

Output:
1
2
3
Python
42


Perfect when you don’t know how many inputs you’ll get!



Why *args?

- Flexible & clean
- Avoids unnecessary overloads
- Makes your code reusable & Pythonic



Follow us for daily Python gems
💡 https://t.iss.one/DataScienceQ


#PythonTips #ArgsInPython #CodingSmart #PythonicWay #DeveloperDaily
🔥2
This media is not supported in your browser
VIEW IN TELEGRAM
0009)
Anonymous Quiz
46%
1
12%
2
38%
3
4%
4
🔥3