META BACK-END DEVELOPER PROFESSIONAL CERTIFICATE
Course 2 – Programming in Python
Week 4: Modules, Packages, Libraries and Tools
Coursera Study Guide
Click to Enroll in Coursera Meta Back-End Professional Certificate
CONTENT
- KNOWLEDGE CHECK: MODULES
- KNOWLEDGE CHECK: POPULAR PACKAGES, LIBRARIES AND FRAMEWORKS
- PRACTICE QUIZ: TESTING QUIZ
- MODULE QUIZ: MODULES, PACKAGES, LIBRARIES AND TOOLS
Supercharge your coding environment with popular modules libraries and tools for Python. You’ll also learn about the different types of testing and how to write a test.
Learning Objectives
- Find, import and use popular Python modules and packages.
- Leverage powerful tools to optimize the programming workflow.
- Explain the types of testing and their features
- Use testing tools to write a test
KNOWLEDGE CHECK: MODULES
1. Assuming there exists a module called ‘numpy’ with a function called ‘shape’ inside it, which of the following is NOT a valid syntax for writing an import statement? (Select all that apply)
- import numpy as dn
- from numpy import shape as s
- from numpy import *
- import shape from numpy (CORRECT)
- import * from numpy (CORRECT)
Correct: Correct! This is an incorrect format.
Correct: Correct! This is an incorrect format.
2. Which of the following locations does the Python interpreter search for modules by default?
- Installation-dependent default directory
- PYTHONPATH or simply the environment variable that contains list of directories
- The current working directory
- Any user-specified location added to the System path using sys package (CORRECT)
Correct: Correct! The location is accessible, but not by default.
3. We can import a text file using the import statement in Python:
- True
- False (CORRECT)
Correct: Correct! Import statement can only be used for importing Python filetypes and packages.
4. Which of the following statements is NOT true about the reload() function?
- The reload() function can be used for making dynamic changes within code.
- You need to import a module before the reload() function can be used over it.
- The reload() function can be used to import modules in Python. (CORRECT)
- You can use the reload() function multiple times for the same module in the given code.
Correct: Correct! The module has to be imported separately. The reload() function cannot import module.
5. Which of the following is NOT to be considered as an advantage of modular programming while using Python?
- Reusability
- Scope
- Simplicity
- Security (CORRECT)
Correct: Correct! While some modules may supply security features, modular programming is not designed by default for security.
6. Which of the following module types are directly available for import without any additional installation when you begin writing our code in Python? (Select all that apply)
- User-defined modules in Home directory of the device
- Third-party packages from Python Package Index not present on the device
- Built-in modules (CORRECT)
- Modules in the current working directory of the Project (CORRECT)
Correct: Correct! Built-in modules are directly available for import without any additional installation when you begin writing our code in Python.
Correct: Correct! Modules in the current working directory of the project are directly available for import without any additional installation when you begin writing our code in Python.
KNOWLEDGE CHECK: POPULAR PACKAGES, LIBRARIES AND FRAMEWORKS
1. Which of these is a popular package that is NOT primarily used in Web development?
- Scikit-learn (CORRECT)
- Pyramid
- Django
- Flask
Correct: Correct! Scikit-learn is used primarily in data science and machine learning.
2. Which of these packages can be applied in the field of Machine learning and Deep learning?
Select all the correct answers.
- Pytest
- Django
- Keras (CORRECT)
- PyTorch (CORRECT)
- TensorFlow (CORRECT)
Correct: Correct! Keras can be applied in the field of Machine learning and Deep learning.
Correct: Correct! PyTorch can be applied in the field of Machine learning and Deep learning.
Correct: Correct! TensorFlow can be applied in the field of Machine learning and Deep learning.
3. Which of the following is not a type of web framework architecture?
- Microframework
- Asynchronous
- Full-stack
- Synchronous (CORRECT)
Correct: Correct! There is no such recognized framework for web development
4. Pandas library in Python cannot be used for which of the following tasks?
- Cleaning, analyzing and maintaining data.
- Visualisation such as graphs and charts. (CORRECT)
- Comparison of different columns in a table.
Correct: Correct! Pandas can assist in plotting, but visualization is assisted with matplotlib library.
5. Which of the following is not a built-in package in the Python standard library?
- Math
- sys
- numpy (CORRECT)
- json
- os
Correct: Correct! numpy is not a built-in package and has to be installed first.
PRACTICE QUIZ: TESTING QUIZ
1. State whether the following statement is True or False:
“Integration testing is where the application or software is tested as a whole and tested against the set requirements and expectations to ensure completeness”
- True (CORRECT)
- False
Correct: Correct! Integration testing is where the application or software is tested as a whole and tested against the set requirements and expectations to ensure completeness.
2. Which of the following is NOT primarily one of the four levels in testing?
- Integration testing
- Unit testing
- System testing
- Regression testing (CORRECT)
- Acceptance testing
Correct: Correct! Regression testing is a type of stress testing that ensures stability of code.
3. Which of the following can be considered a valid testing scenario? (Select all that apply.)
- Check for negative value acceptance in numeric field (CORRECT)
- If the webpage resizes appropriately according to the device in use (CORRECT)
- Deletion or form updation should request confirmation (CORRECT)
- Broken links and images should be checked before loading a webpage (CORRECT)
Correct: Correct! Checking for negative value acceptance in numeric field is considered a valid testing scenario.
Correct: Correct! If the webpage resizes appropriately according to the device in use is considered a valid testing scenario.
Correct: Correct! Deletion or form updation requesting confirmation is considered a valid testing scenario.
Correct: Correct! Checking broken links and images before loading a webpage is considered a valid testing scenario.
4. What can be considered as an ideal testing scenario?
- Designing test cases in the shortest amount of time.
- Finding the maximum bugs and errors.
- Using the minimal number of testing tools to find defects.
- Writing the least number of tests to find largest number of defects. (CORRECT)
Correct: Correct! Writing the least number of tests to find largest number of defects is the ideal testing scenario.
5. Which job roles are not always a part of the testing lifecycle working on an application or product?
- Tester
- Project Manager
- Stakeholder (CORRECT)
- Programmers other than tester
Correct: Correct! Stakeholders and end-users may or may not participate in the testing lifecycle.
MODULE QUIZ: MODULES, PACKAGES, LIBRARIES AND TOOLS
1. Which of the following is not true about Test-driven development?
- The process can also be called Red-Green refactor cycle.
- It ensures that the entire code is covered for testing.
- Test-driven development can only have one cycle of testing and error correction. (CORRECT)
- In TDD, the requirements and standards are highlighted from the beginning.
Correct: Correct! The test-driven development can have more than one cycle of testing and error correction
2. Which of the following is a built-in package for testing in Python?
- PyTest
- Pyunit or Unittest (CORRECT)
- Selenium
- Robot Framework
Correct: Correct! The built-in package is called a Pyunit or Unittest.
3. Which of the following is an important keyword in Python used for validation while doing Unit testing?
- Yield
- Async
- assert (CORRECT)
- lambda
Correct: Correct! Assert equates to the boolean result of the statements.
4. Which of the following ‘V’s’ is not identified as a main characteristic of Big Data?
- Velocity
- Volume
- Variability
- Variety (CORRECT)
Correct: Correct! Variety is not identified as a main characteristic of Big Data.
5. What will be the output of the following piece of code:
from math import pi
print(math.pi)
- NameError: name ‘math’ is not defined (CORRECT)
- There will be no output
- 3.141592653589793
- ImportError: No module named math
Correct: Correct! This is the correct output of the code.
6. Which of the following is NOT primarily a package used for Image processing or data visualization?
- Seaborn
- OpenCV
- Scrapy (CORRECT)
- Matplotlib
Correct: Correct! Scrapy is used for web scraping.
7. _______ is/are the default package manager(s) for installing packages in Python.
- Pip (CORRECT)
- Python Standard Library
- Built-in Module
- Python Package Index (pypi)
Correct: Correct! This is the class variable as it is declared within the class
8. If you are working on some codeblock, which of the following can be ‘imported’ in it from external source?
Select all that apply.
- Variables (CORRECT)
- Packages (CORRECT)
- Modules (CORRECT)
- Functions (CORRECT)
Correct: Correct! You can import variables in a codeblock.
Correct: Correct! You can import packages in a codeblock.
Correct: Correct! You can import modules in a codeblock.
Correct: Correct! You can import functions in a codeblock.
9. As a Python developer at Little Lemon, you know that there are various advantages of modules in Python. Which one of these advantages will help you to avoid inter-dependency among your Python modules.
- Reusability
- Simplicity (CORRECT)
- Scope
Correct: That’s correct! Simplicity in Python modules help to avoid inter-dependency.
10. One of your colleagues at Little Lemon approached you and asked you if the following statement is true: “Can any Python file be a module?” What will your answer be?
- No
- Yes (CORRECT)
Correct: That’s right! Any Python file can be a module.
11. As a Python developer at Little Lemon, you know that Python has a library of standard modules available called built-in modules. You also know that these modules are directly built into the Python interpreter and must be installed separately. Is your understanding correct?
- No (CORRECT)
- Yes
Correct: That’s correct! Python has a library of standard modules available called built-in modules. These modules are directly built into the Python interpreter and don’t have to be installed separately.
12. You are developing an app for Little Lemon using Python and you want to import all the functions inside a specific module. Once you have removed your code, which one of the following would you replace your code with?
- Hash symbol #
- Star symbol * (CORRECT)
- Equals to (==)
Correct: That’s correct! You can remove your code and replace it with a star. This translates to “import all from the specific module.”
13. You are busy programming and using variables. You are struggling to remember in which scope some of your variables belong to do a scope resolution. Which rule should you use to do this resolution?
- LEGB (CORRECT)
- BILG
- LAFG
Correct: That’s correct! You should use the LEGB rule which stands for Local, Enclosed, Global and Built-in.
14. You have previously imported a module into the code that you are writing in Python to enhance their workflow in the system. You know that the import statement is only loaded once by the Python interpreter. So, you ask a colleague if the reload function can import and reload the import statement more than once. His answer is:
- Yes (CORRECT)
- No
Correct: Yes, the reload function lets you import and reload it multiple times.
15. True or false: Built-in packages are available as soon as you install Python and are commonly used in may projects.
- False
- True (CORRECT)
Correct: Built-in packages don’t need to be installed separately and can be used as soon as you’ve installed Python. Almost every project uses one or more of these built-in packages, so it’s worth getting to know them well.
16. Which of the following packages are used for Data Analysis? Select all that apply.
- Quantum computing
- Matplotlib (CORRECT)
- NumPy (CORRECT)
- Scikit-Learn (CORRECT)
Correct: Well done! Matplotlib, NumPy, Scikit-Learn are used for Data Analysis.
17. What are examples of some fields that may utilize machine learning? Check all that apply.
- Natural language processing (CORRECT)
- Speech recognition (CORRECT)
- Computer vision (CORRECT)
- Deep learning (CORRECT)
- Sentiment analysis (CORRECT)
- Recommender engines (CORRECT)
Correct: Machine learning is used in natural language processing.
Correct: Machine learning is used in speech recognition.
Correct: Machine learning is used in computer vision.
Correct: Machine learning is used in deep learning.
Correct: Machine learning is used in sentiment analysis.
Correct: Machine learning is used in recommender engines.
18. What are some of the most popular web frameworks in Python? Select all that apply.
- Flask (CORRECT)
- Django (CORRECT)
Correct: Well done. Flask is one of the most widely used are Flask and Django.
Correct: Well done. Django is of the most widely used are Flask and Django.
19. Testing is a crucial part of the software development life cycle. Which of the following statements apply to software testing? Choose all that apply.
- Testing is only done in the later stages of the software life cycle.
- Testing helps to find security vulnerabilities. (CORRECT)
- It’s focused on performance, correctness and completeness. (CORRECT)
- Testing should have the least tests written to find the largest number of defects. (CORRECT)
Correct: That’s correct. Security concerns are important and need to be addressed during testing.
Correct: That’s correct. Testing is about ensuring that the product has as few problems as possible.
Correct: That’s correct. Efficiency is an important part of software testing.
20. Which of the following are the main levels of testing? Check all that apply.
- Functional testing
- Maintenance tests
- Unit testing (CORRECT)
- Acceptance testing (CORRECT)
- System testing (CORRECT)
- Integration testing (CORRECT)
Correct: That’s correct! In unit or component testing, the program tests specific individual components by isolating them.
Correct: That’s correct! This is when the stakeholders and a select few end-users are involved in acceptance testing.
Correct: That’s correct! System testing is testing all the software.
Correct: That’s correct! Integration testing combines the unit tests and tests the flow of data from one component to another.
21. You need to automate your tests. Can you identify the order in which the ideal steps in the test automation process are performed?
- Analyzing the results, preparing the test environment and running the test scripts.
- Running the test scripts, preparing the test environment and analyzing the results.
- Preparing the test environment, running the test scripts and analyzing the results. (CORRECT)
Correct: Correct! This is the order in which the idea steps in the test automation process are performed.
22. PyTest is one of the most popular modules for unit testing in Python. You should use the pass keyword instead of the assert keyword with tests.
- Yes
- No (CORRECT)
Correct: That’s correct. You use the assert keyword because it checks for conditions in your code and expects a Boolean value of true or false. When the return value is true, the test passes. If the return value is false then the test fails. The pass keyword just passes a test without checking.
23. You are currently developing software for Little Lemon using Python. You are now in your software development stage where you need to do testing. You decide to use “Unittest”. You mention this to your colleague and he asks you what the benefit of “Unittest” is. What will your answer be?
- “Unittest” can be imported into Python
- “Unittest” has useful libraries. (CORRECT)
Correct: That’s correct! “Unittest” has useful libraries such as “Unittest.mock” that can mock large functions, removing the time and memory overhead.
24. What are the steps for applying the test-driven development methodology? Select all that apply.
- Write code and then write test cases.
- Refactor code in case the tests fail. (CORRECT)
- Write code in accordance with the test cases ensuring that they pass. (CORRECT)
- Write test cases with some functionality in mind. (CORRECT)
Correct: Correct! This is an example of test-driven development methodology.
Subscribe to our site
Get new content delivered directly to your inbox.
Quiztudy Top Courses
Popular in Coursera
- Meta Marketing Analytics Professional Certificate.
- Google Digital Marketing & E-commerce Professional Certificate.
- Google UX Design Professional Certificate.
- Meta Social Media Marketing Professional Certificate
- Google Project Management Professional Certificate
- Meta Front-End Developer Professional Certificate
Liking our content? Then, don’t forget to ad us to your BOOKMARKS so you can find us easily!