Input a list/tuple of elements search for a given element in the list/tuple. This Computer Science (Python) practical is asked in the new CBSE Term 2 class 11 syllabus. There is a list of 5 programs in the syllabus. We have presented all the practical file for class 11 computer science with python in the home page of this site.
Exercise 3 : Input a list/tuple of elements search for a given element in the list/tuple.
# Python code to find the tuples containing # the given element from a list of tuples # List of tuples Input = [(14, 3),(23, 41),(33, 62),(1, 3),(3, 3)] # Find an element in list of tuples. Output = [item for item in Input if item == 3 or item == 3] # printing output print(Output)
- Here first a list of tuple is entered with list as elements.
- Then the condition is checked whether the first or second one of list is equal to 3.
- If it is equal to 3 then it is presented as output in tuple containing list.
[(14, 3), (1, 3), (3, 3)]
Thank you for learning from this post. We wish all of the best for class 11 computer science with python exams. Python is one of the most easiest and powerful language. I am impressed that CBSE is teaching Python. I feel if you go into information and communication field your carrier will be secured. Python is mainly used in data analysis and artificial intelligence programs and software’s. With the whole new generation of students in CBSE board learning Python it gives me pride to devote time for solving and presenting the work. This practical file questions are solved by Experts and every day Programmers. Here we have presented the code in most simple way of programming and yet the most powerful code for our practical. For securing full marks bookmark this website as it will help you to sail through Practicals, projects and pythons questions and answers of CBSE computer science (Python.. I am sure computer science work is nice and benefit the learners. Here below whole practical Practical file is given with link.
Computer Science with Python Practical Book Solutions Class 11 Term -2 – CS Study