Python Modules Assignment
Python Modules assignment is designed to assist Python Tutorial on Modules.
Q1. How to display all available modules in your current python setup.
Q2. Write Python command to check the help of any function available in the random module.
Q3. How to import a single function from a module.
Q4. Write Python command to show the help in a single module function
Q5. Write python command to show all the available function of the statistics module
Q6. Find out the output produced by the following program code
import random as r print(r.random()*10) print(r.random()*100) print(round(r.random()*10,2)
Q7. Find out the largest number produced by the following command
a) import random as r print(r.randint(10,15)) b) import random.randrange print(randrange(1,21))
Q8. What possible outputs(s) are expected to be displayed on the screen at the time of execution of the program from the following code? Also, specify the maximum values that can be assigned to each of the variables Lower and Upper.
import random AR=[20,30,40,50,60,70] Lower = random.randint(1,3) Upper =random.randint(2,4) for K in range(Lower, Upper +1): print (AR[K],end=”#“) (i) 10#40#70# ( ii) 30#40#50# (iii) 50#60#70# (iv) 40#50#70#
Q9. Name the Python Library modules which need to be imported to invoke the following functions: \
(i) sin() (ii) randint ()
Q10. What are the possible output(s) of the following code? Also, specify the maximum and
minimum values that can be assigned to the variable PICKER.
import random PICK = random.randint(0,3) CITY= [“DELHI”, “MUMBAI”, “CHENNAI”,”KOLKATA”] for x in CITY: for y in range(1, PICK): print (x, end = “ “) print() (i) DELHI DELHI (ii) DELHI MUMBAI MUMBAI MUMBAI CHENNAI CHENNAI CHENNAI KOLKATA KOLKATA KOLKATA (iii) DELHI (iv) DELHI DELHI MUMBAI MUMBAI MUMBAI DELHI MUMBAI CHENNAI KOLKATA KOLKATA KOLKATA
Besides this, Other Python Assignments, Assignments on the list, tuple, and dictionaries also recommended.