Quick Solution for Reference
Section – A
(Attempt all Questions - Short Answer/Definitions)
1. What is matplotlib?
Answer: Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. It is widely used for plotting graphs like line charts, bar charts, histograms, and scatter plots using its pyplot module.
2. What is pandas?
Answer: Pandas is an open-source Python library used for data manipulation and analysis. It provides high-performance data structures like Series (1D) and DataFrames (2D), making it easy to clean, analyze, and manipulate structured data.
3. What is range()?
Answer: The range() function in Python is a built-in function used to generate a sequence of numbers. It is commonly used in loops (like for loops) to iterate a specific number of times. It takes three arguments: start (inclusive), stop (exclusive), and step.
4. What is dictionary?
Answer: A dictionary in Python is a mutable, unordered collection of items. Each item consists of a key and a value pair (written as key: value). Keys must be unique and immutable (like strings or numbers), while values can be of any type.
5. What is Linear search?
Answer: Linear search is a simple searching algorithm that checks every element in a list sequentially from the start until the desired element is found or the list ends. Its time complexity is O(n).
Section – B
(Attempt any two questions)
6. Explain the term class and object in object-oriented programming?
Answer:
- Class: A Class is a blueprint or template for creating objects. It defines a set of attributes (variables) and methods (functions) that the created objects will have. It does not occupy memory until an object is instantiated.
- Example: A class
Carmight define attributes likecolorandmodel.
- Example: A class
- Object: An Object is an instance of a class. When a class is defined, no memory is allocated, but when it is instantiated (i.e., an object is created), memory is allocated. An object allows you to access the variables and functions defined in the class.
- Example:
my_car = Car()creates an object namedmy_car.
- Example:
7. What do you mean by Python IDE? Explain in detail?
Answer: Python IDE (Integrated Development Environment) is a software application that provides comprehensive facilities to computer programmers for software development. An IDE typically combines a source code editor, build automation tools, and a debugger into a single graphical user interface (GUI).
Key Features:
- Syntax Highlighting: Colors code to make it easier to read.
- Autocomplete/Intellisense: Suggests code completions to speed up typing.
- Debugging Tools: Allows developers to step through code to find errors.
- Project Management: Helps organize files and resources.
Examples of Python IDEs:
- PyCharm: A popular, feature-rich IDE specifically for Python.
- VS Code: A lightweight, highly extensible code editor widely used for Python.
- Jupyter Notebook: Great for data science and interactive coding.
Section – C
(Attempt any one question)
8. Discuss the difference between local and global Variable?
Answer:
| Feature | Local Variable | Global Variable |
| Scope | Declared inside a function and can only be accessed within that function. | Declared outside all functions and can be accessed throughout the program. |
| Lifetime | Created when the function starts and destroyed when the function ends. | Created when the program starts and remains until the program terminates. |
| Access | Cannot be accessed by other functions. | Can be accessed and modified by any function in the code. |
| Modification | Can be modified directly inside the function. | To modify a global variable inside a function, the global keyword is required. |
9. What is numpy? Why it is used.
Answer:
NumPy (Numerical Python) is a fundamental library for scientific computing in Python. It provides support for large, multi-dimensional arrays and matrices, along with a collection of high-level mathematical functions to operate on these arrays.
Why it is used (Key Advantages):
- Performance: NumPy arrays are significantly faster and more compact than standard Python lists because they are stored in contiguous memory blocks.
- Vectorization: It allows you to perform operations on entire arrays without writing explicit loops (e.g., adding two arrays together in one line).
- Mathematical Functions: It includes powerful tools for linear algebra, Fourier transform, and random number generation.
- Integration: It serves as the foundation for other libraries like Pandas, Matplotlib, and Scikit-learn.