Question 1: Which of these is not a module?
A. libraries
B. functions
C. classes
D. files
E. None of the above.
Answer:
All of these are modules: libraries, functions, classes and files.
Correct answer: E
~~~
Question 2:
What will this print:
import pandas
df = pandas.DataFrame([1, 2])
print(__name__)
~~~
Q3:
What will this print:
import pandas
df = pandas.DataFrame([1, 2])
print(pandas.__name__)
~~~
Q4:
What will this print:
import pandas as pd
df = pandas.DataFrame([1, 2])
print(pd.__name__)
Q5:
What will this print:
from pandas import DataFrame
print(DataFrame.__name__)
Q6: What will this print:
from pandas import DataFrame
print(pandas.__name__)
Answer: NameError: name 'pandas' is not defined
Rules of Thumb
For libraries:
Remove the .py filename extension to get the __name__ of any library.
For Classes and Functions:
The __name__ is the same as the name of the class.
~~~
Q7: What will this print:
++++ File: import_me.py ++++
def call_me():
print("Hello!!!")
call_me()
++++ File: run_me.py ++++
from import_me import call_me
call_me()
print(5+5)
Output:
Hello!!!
Hello!!!
10
~~~
Pages
- Index of Lessons in Technology
- Index of Book Summaries
- Index of Book Lists And Downloads
- Index For Job Interviews Preparation
- Index of "Algorithms: Design and Analysis"
- Python Course (Index)
- Data Analytics Course (Index)
- Index of Machine Learning
- Postings Index
- Index of BITS WILP Exam Papers and Content
- Lessons in Investing
- Index of Math Lessons
- Index of Management Lessons
- Book Requests
- Index of English Lessons
- Index of Medicines
- Index of Quizzes (Educational)
Friday, August 9, 2024
Questions on: If __name__ == '__main__' ( A Python Lesson )
To See All Python Articles: Python Course (Index)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment