63 solutions available
Question 1Assertion (A): The random module is a built-in module to generate pseudorandom variables.Reasoning (R): The randrange() function is used to...
Question 2Assertion (A): The randint() method returns an integer from the specified range.Reasoning (R): The syntax for randint() is: random.randint...
Question 3Assertion (A): The function ceil() is a commonly used function from math module.Reasoning (R): The ceil() function takes a numeric argument...
Question 4Assertion (A): Some of the real-life applications of random module include CAPTCHA, OTP generation, automatic password generator and...
Question 5Assertion (A): The median() method returns the middle value of numeric data in a list.Reasoning (R): The math module contains both...
Question 6Assertion (A): Python has a built-in math module that you can use for mathematical tasks.Reasoning (R): The mean() method calculates the...
Question 7Assertion (A): Python modules are .py files that contain Python code.Reasoning (R): The import statement allows you to import all the...
Question 8Assertion (A): The output of print(math.factorial(4.5)) shall generate an error.Reasoning (R): This factorial() function belongs to the...
Question 1A Python library is a collection of modules and packages.
Question 2A module is a Python file that constitutes only definitions of variables, functions and classes.
Question 3The import statement reads a module file and makes its contents available for use.
Question 4math module in Python provides mathematical functions.
Question 5ceil() function returns the closest integer value greater than or equal to a floating point number.
Question 6mode() function returns a set of data values that appear most often in a data set.
Question 7The output of the following statement: X = statistics.mean([2, 15, 16, 19] =) is 13.
Question 8To access a method/function from a module, we have to specify the name of the function separated by a dot(.) operator.
Question 9A module can be classified as either built-in or user-defined.
Question 10A module constitutes two sub-components—executable statements as well as function definitions.
Question 11help() function is used to get all information about module, i.e., name of all functions, variables, etc, available in that module.
Question 1What is the output of math.ceil(4.4) ?544.05.0
Question 2What will be the output on screen after executing: print(math.fabs(-6.4)) ?-6.46.446
Question 3If a, b, c = 3, 4, 1 then what will be the value of math.sqrt(b)*a-c?5.0524.0
Question 4What is the value of x, if x = math.factorial(0) ?10ErrorNone of these
Question 5What is the value of x, if x = math.sqrt(25.0) ?(5, -5)55.0(5.0, -5.0)
Question 6What value will be returned, if x = math.floor(-24.6) ?24.6-24-25-24.6
Question 7What value will be displayed on executing the following arithmetic expression?x = math.pow (0,-4)116DomainErrorNone of these
Question 8What output will be displayed after executing the following code?statistics.median([11, 22, 33, 44, 55, 66])28.538.55.56.5
Question 9On executing the following code, what output will be displayed?statistics.mode([2.5, 3.2, 3.3, 2.5, 8.1, 9.9, 2.5, 5.1])2.53.25.18.1
Question 10What will the following code display on execution?X = statistics.mean([2, 15, 6, 19])10.510.6ErrorNone of these
Question 11To include the use of functions which are present in the random library, we must use the option:import...
Question 12What will be the output of the following code:>>> import statistics >>> statistics.mode([2, 5, 3, 2, 8, 3, 9, 4, 2, 5,...
Question 1What is a Python library? Explain with examples.
Question 2Write a module to input total number of days and find the total number of months and remaining days and display it in another program.
Question 3What is a module? What is the file extension of a Python module?
Question 4How do you reuse the functions defined in a module in your program?
Question 5In how many ways can you import objects from a module?
Question 6How are the following two statements different from each other?(a) import math(b) from math import*
Question 7What is the utility of math module?
Question 8How does Python resolve the scope of a name or identifier?
Question 9A program having multiple functions is considered better designed than a program without any functions. Why?
Question 10Write a module called calculate_area() that takes base and height as an input argument and returns an area of a triangle as output. The...
Question 11Rewrite the following Python code after removing all syntax error(s). Underline the corrections done.def main(): r = input('enter any...
Question 12How is math.ceil(89.7) different from math.floor(89.7)?
Question 13Out of random() and randint(), which function should we use to generate random numbers between 1 and 5. Justify.
Question 14What is the difference between import statement and from import statement?
Question 15Why is from import* statement not recommended for importing Python modules in an external program?
Question 16Write a function to calculate volume of a box with appropriate default values for its parameters. Your function should have the following...
Question 17Consider the amount of donations received by a charitable organization given as under:donations = [100, 60, 70, 900, 100, 200, 500, 500,...
Question 18Write a Python program to generate a random number between 0 and 9.Solutionimport random random_number = random.randint(0, 9)...
Question 19Define a function which accepts n as an argument and prints Fibonacci series till n.Solutiondef print_fibonacci(n): a, b = 0, 1...
Question 20Consider the temperature given below for the month of June in North India. Calculate the average temperature and median value. This...
Question 21Create a menu-driven program using user-defined functions to implement a calculator that performs the following:(a) Basic arithmetic...
Question 22Write a program that contains user-defined functions to calculate area, perimeter or surface area whichever is applicable, for various...
Question 1A module line (header) is written only once at the top of the program.
Question 2A function call can be made several times in a Python module.
Question 3A module is loaded only once regardless of the number of times it is used.
Question 4The statement to import math module is—call math.
Question 5A module is not necessarily to be imported before being used.
Question 6floor() returns the closest integer value less than or equal to a floating point number.
Question 7fabs() returns the same number if it is a negative value.
Question 8math.sqrt(x) returns a ValueError if x is a negative number.
Question 9The mean() method calculates the arithmetic mean of the numbers in a list.
Question 10Each time we use the randint() function, it produces different results.