Q5) Write a program that sort a list of tuple–elements in descending order of Points using Bubble sort. That is the smallest–length string should be the first string in the list and the largest–length string should be the last string in the sorted list. Q4) Write a program to perform sorting on the given list of strings, on the basis of length of strings. Then write an insertion sort function that sorts the list on the basis of one’s digit of all elements. Q3) Write a program to read a list containing 3-digit integers only. Each element of the list is a tuple containing details of the one nobel prize winner.L = Write a program to short the list in the order of last names of the winners. Q2) Given following list L that stores the names of Nobel prize winners. Print the name of candidates with votes received in decreasing order of the number of votes received. Interface python with an SQL database Database connectivity: - Database connectivity refers to connection and communication between an application and a database system. List A will contain the name of the candidate and list B will contain the votes received by candidate list A. Interface python with an SQL database Notes Sumita Arora Class 12 Computer science Note:- PDF Download link given below of this Blog. Write a program that sorts the contents of the election dictionary and create two list that stores the sorted data. Q1) Election is a dictionary where key : value pair are in the form of name : votes received. print(statistics.mode())ĭisclaimer : I tried to give you the correct Notes of ” Introduction to Python Modules ”, but if you feel that there is/are mistakes in the Notes of “ Introduction to Python Modules “ given above, you can directly contact me at MCQ of Computer Science Chapter WiseĢ.Understanding Sorting || Type C || Sumita Arora || Class 11 || Computer science || Information practices || Solution Write the output of the following : import statisticsĬ. Write the output of the following import math Write the output of the following : import math Random Module : Click here for notes and questions mode( ) : This function returns the mode ie a number with maximum number of occurrence. mean( ) : This function returns the average of the data passed as an argument. median( ) : This function returns the median of the data. Statistics Module : Functions of statistics module are discussed below:Ī. e : It returns the mathematical constant import math Output : 1.6197751905438615 NOTE : Value passed in this function should be in radian. tan( ) : This function returns the tangent of value passed as argument. Output : 0.5253219888177297 NOTE : Value passed in this function should be in radian. cos( ) : This function returns the cosine of value passed as argument. Output : 0.8509035245341184 NOTE : Value passed in this function should be in radian Introduction to Python Modules sin( ) : This function returns the sine of value passed as argument. pow(m, n) : This function returns m raise to the power n. ceil(n) : This function returns the smallest integer which is more than or equal to n. Print(math.floor(23.96) Output : 23 Introduction to Python Modulesī. floor(n) : This function returns the largest integer which is less than or equal to n. Let we discuss few functions of math module.Ī. Math module : This module has many mathematical functions like ceil, floor, sqrt etc. Some of the common built-in modules are:ġ. Built-in Modules : There are many built in modules in Python Library. Using import* statement : This statement can be used to import all functions of a specific module likeġ. To import more than one function of a module, we can writeģ. Using ‘from’ statement : This method allow us to import specific function of a module. To use more than one module like math and random in our code, we can write :Īfter importing module in our code, we can access a specific function by writing:Ģ. for example : to use math module, we can write. This method allow us to access all the functions/objects defined in the module. Using import statement : This is one of the most common way to use module in Python. There are three ways to import a module in Python.ġ. Introduction to Python Modules Importing Python modules
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |