NCERT solutions Working with Lists and Dictionaries
1. What will be the output of the following statements?
a) list1 = [12,32,65,26,80,10]
list1.sort()
print(list1)
Ans.: [10,12,26,32,65,80] | |
b) list1 = [12,32,65,26,80,10] | |
Ans.: [12,32,65,26,80,10] | |
c) list1 = [1,2,3,4,5,6,7,8,9,10] | |
Ans.: | |
d) d) list1 = [1,2,3,4,5] | |
Ans.: 5 | |
2. Consider the following list myList. What will be the elements of myList after each of the following operations? myList = [10,20,30,40] a) myList.append([50,60]) | |
The output will be: [10,20,30,40,[50,60]] | |
b) myList.extend([80,90]) | |
The output will be: [10,20,30,40,[50,60],80,90] | |
3. What will be the output of the following code segment? | |
The output will be: | |
NCERT solutions Working with Lists and Dictionaries4. What will be the output of the following code segment? del myList[3:] | |
The output will be [1,2,3] | |
b) myList = [1,2,3,4,5,6,7,8,9,10] | |
The output will be [6,7,8,9,10] | |
c) myList = [1,2,3,4,5,6,7,8,9,10] | |
The output will be [2,4,6,8,10] | |
5. Differentiate between append() and extend() methods of list. append() extend() Examples | |
NCERT solutions Working with Lists and Dictionaries | |
6. Consider a list: | |
a) The * operator treated as a replication operator when the list object is referred to with any numeric value. So here it will replicate the list values. Therefore it returns [6,7,8,9,6,7,8,9] | |
7. The record of a student (Name, Roll No, Marks in five subjects and percentage of marks) is stored in the following list: | |
perc=stRecord[3] | |
b) Marks in the fifth subject | |
marks_sub5 = stRecord[2][4] | |
c) Maximum marks of the student | |
marks_max = max(stRecord[2]) | |
d) Roll No. of the student | |
rno = stRecord[1] | |
e) Change the name of the student from ‘Raman’ to ‘Raghav’ | |
sname = stRecord[0] | |
8. Consider the following dictionary stateCapital: stateCapital = {“Assam”:”Guwahati”, “Bihar”:”Patna”,”Maharashtra”:”Mumbai”, “Rajasthan”:”Jaipur”} a) print(stateCapital.get(“Bihar”)) | |
The output will be – Patna | |
b) print(stateCapital.keys()) | |
The output will be – dict_keys([‘Assam’, ‘Bihar’, ‘Maharashtra’, ‘Rajasthan’]) | |
c) print(stateCapital.values()) | |
The output will be – dict_values([‘Guwahati’, ‘Patna’, ‘Mumbai’, ‘Jaipur’]) | |
d) print(stateCapital.items()) | |
The output will be – dict_items([(‘Assam’, ‘Guwahati’), (‘Bihar’, ‘Patna’), (‘Maharashtra’, ‘Mumbai’), (‘Rajasthan’, ‘Jaipur’)]) | |
e) print(len(stateCapital)) | |
The output will be – 4 | |
f) print(“Maharashtra” in stateCapital) | |
The output will be – True | |
g) print(stateCapital.get(“Assam”)) | |
The output will be – Patna | |
h) del stateCapital[“Assam”] print(stateCapital) | |
It will delete information related to Assam. and print other keys and values. | |
NCERT solutions Working with Lists and DictionariesProgramming Problems1. Write a program to find the number of times an element occurs in the list. By using loops | |
l = [ ] | |
| |
lval = eval(input(“Enter the values for the list:”)) | |
2. Write a program to read a list of n integers (positive as well as negative). Create two new lists, one having all positive numbers and the other having all negative numbers from the given list. Print all three lists. | |
lval = eval(input(“Enter the values for the list:”)) | |
3. Write a program to find the largest and the second-largest elements in a given list of elements. | |
L = eval(input(“Enter the values for the list:”)) | |
4. Write a program to read a list of n integers and find their median. : Use an inbuilt function to sort the list. | |
import statistics as s | |
5. Write a program to read a list of elements. Modify this list so that it does not contain any duplicate elements i.e. all elements occurring multiple times in the list should appear only once. | |
l = eval(input(“Enter the values:”)) | |
6. Write a program to create a list of elements. Input an element from the user that has to be inserted in the list. Also input the position at which it is to be inserted. | |
l = [1,2,3] | |
7. Write a program to read elements of a list and do the following. | |
l = [1,2,3] | |
b) The program should ask for the value of the element to be deleted from the list and delete this value from the list. | |
l = [1,2,3] | |
8. Write a Python program to find the highest 2 values in a dictionary. | |
d = {11:22,33:46,45:76} | |
9. Write a Python program to create a dictionary from a string ‘w3resource’ such that each individual character mates a key and its index value for fist occurrence males the corresponding value in the dictionary. Expected output : {‘3’: 1, ‘s’: 4, ‘r’: 2, ‘u’: 6, ‘w’: 0, ‘c’: 8, ‘e’: 3, ‘o’: 5} | |
strr = ‘w3resource’ | |
10. Write a program to input your friend’s, names and their phone numbers and store them in the dictionary as the key-value pair. Perform the following operations on the dictionary: | |
n = int(input(‘Enter the number of friends ‘)) | |
a) Display the Name and Phone number for all your friends | |
d = dict(l) | |
b) Add a new key-value pair in this dictionary and display the modified dictionary | |
n = int(input(‘Enter how many more freinds you want to enter’)) | |
c) Delete a particular friend from the dictionary | |
nn =input(‘Enter name to remove ‘) | |
d) Modify the phone number of an existing friend | |
nam = input(‘Enter the name to change number ‘) | |
e) Check if a friend is present in the dictionary or not | |
nnm = input(‘Enter the name to search ‘) | |
f) Display the dictionary in sorted order of names | |
print(dict(sorted(d.items()))) NCERT Class 11 Solutions can be of great value if you are trying to excel in your school examinations. The journey starts directly from when you step into class 1 as every class holds great to use as you progress. CBSE Class 11 is no doubt a very valuable class and the last class of your school life. Not to mention, it also leads to a lot of career-making decisions as you seem for some important competitive exams to get your desire college. NCERT solution can help you immensely throughout this adventure of yours. NCERT Class 11 SolutionsAlthough higher classes students like Class 10-12 should have a better knowledge of all the topics that will help them to examine deeper into the basics as well as an advanced level of questions that are asked in many competitive exams after 12 class. One of the best ways to achieve it is by answering questions of NCERT Books with the help of NCERT solutions. We at SelfStudys strive hard to devise better ideas in order to help students and give you detailed solutions for all questions from the NCERT textbook as per the latest CBSE CCE marking scheme pattern is to back you up in useful learning in all the exams conducted by CBSE curriculum. The plethora of advantages of referring to NCERT solutions requires an in-depth understanding of detailed solutions of all NCERT book’s questions. We have given all the detailed NCERT questions and solutions in PDF format which you can read for FREE. All you have to do is download the SelfStudys NCERT Solutions for Class 11 once for FREE and you are able to go. You can get all the Subject NCERT solutions by the links provided here. NCERT Solutions for all the subjects of Class 11 is available on this page including NCERT Class 11 Solution for Maths, Chemistry, Physics, English, Business Studies, Biology, economics are provided below to download in a free PDF file. NCERT Solution for Class 11NCERT Class 11 Solutions to the questions with Chapter-wise, detailed are given with the objective of helping students compare their answers with the example. NCERT books provide a strong foundation for every chapter. They ensure a smooth and easy knowledge of advanced concepts. As suggested by the HRD ministry, they will perform a major role in JEE. NCERT Class 11 Solutions | NCERT Solution for Class 11NCERT Solution for Class 11 includes all the questions given in NCERT Books for all Subjects. Here all questions are solved with detailed information and available for free to check. NCERT Solutions for Class 11 are given here for all chapter-wise. Select the subject and choose a chapter to view NCERT Solution chapter-wise. We hope that our NCERT Class 11 Solutions helped with your studies! If you liked our NCERT Solutions for Class 11, please share this post. Why NCERT Solutions for Class 11 is Important?NCERT Class 11 Solutions increases the base for conceptual knowledge. It provides a complete view of the prescribed syllabus, as the textbook doesn't have a detailed description of the syllabus nor solutions. All the important theorems and formulas of Class 11 are completely solved, which works to make the concepts and find new links to them. Importantly, the NCERT Class 11 Solutions is the point of reference for those students planning for competitive examinations such as NRRT, JEE Main/Advanced, BITSAT & VITEEE, etc. When the NCERT book is accompanied by the solutions, the knowledge of concepts becomes simple and in-depth. Moreover, students can trail into the solutions without break in topics, as it is designed to give a step-by-step explanation. Try out the Class 11 Solutions and learn from the resources. Why try NCERT Class 11 Solutions?Well, here are the solid reasons why you should and must try out the NCERT Class 11 Solutions. Has ERRORLESS answers with 100% Reasoning The quality of solutions is perfect Gives in-depth knowledge with notes shortly after the solutions with shortcuts, tips, alternative methods & points to remember Gives quick revision of the concepts included along with important definitions and Formulas on the chapters, which acts as a prepared refresher. Designed step-by-step to give 100% Concept Clearness | |
No comments:
Post a Comment
Have query? Just say it.