Computer Science
Assertion (A): Python modules are .py files that contain Python code.
Reasoning (R): The import statement allows you to import all the functions from a module into your code.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Python Modules
2 Likes
Answer
Both A and R are true and R is the correct explanation of A.
Explanation
A module is created as a python (.py) file containing a collection of function definitions, classes and variables. The import statement can be used to import a module. It is the simplest and most common way to use modules in our code. It provides access to all attributes (like variables, constants etc) and methods or functions present in the module.
Answered By
2 Likes
Related Questions
Define a function which accepts n as an argument and prints Fibonacci series till n.
Consider the temperature given below for the month of June in North India. Calculate the average temperature and median value. This temperature gets dipped with a variation of 20°C in the month of December. Write a Python program to calculate the changed median value and average temperature.
Location Temperature (in °C) Delhi 41 Shimla 32 Chandigarh 43 Rohtak 40 Srinagar 28 Sri Ganganagar 45 Create a menu-driven program using user-defined functions to implement a calculator that performs the following:
(a) Basic arithmetic operations (+, −, *, /)
(b) log10(x), sin(x), cos(x)
Write a program that contains user-defined functions to calculate area, perimeter or surface area whichever is applicable, for various shapes like square, rectangle, triangle, circle and cylinder. The user-defined functions should accept the values for calculation as parameters and the calculated value should be returned. Import the module and use appropriate functions.