35.Programming Assignment 8 ( using lists)

Now you can try the following programs using Lists

1.Read list of numbers and check whether the given element in found in the list. If found display the positions else display the message element is not found.( index() method only find the first occurrence. use a loop)
2.Count the number of occurrences of an element in a list. ( use count() method or use a loop)
3.Read a list and remove the first and last element .Create a new list( use del(), pop() and slicing)
4. Write program to read list of names and print the names in sorted order.(use sort())
5. Read list of numbers and print the list in reverse sorted order.(use sort())
6. Program to find the sum of all even numbers in a group of ‘n’ numbers entered by the user. (university question)
7. Write a Python program to count the number of –ve terms and zeros in a given set of n numbers (university question)
8. Write a Python program to input a list of ‘n’ numbers. Calculate and display the average(mean) of ‘n’ numbers. Also display cube of each value in the list.(university question)
9.Read a list of ‘n’ numbers and find the smallest and largest among them.(use min() and max())
10.Find the second largest and second smallest element from a list.( use sort().min(),max())
11.Read list of numbers and find the median.(refer example)
12.Read list of numbers and find the standard deviation.
13.Find the duplicate elements from a list.( use count())
14.Read a string and print the words in alphabetical order ( use split() and sort())
15.Read a string and print each words and its length.Also print number of words.(use split() and len())
16.Read a string and remove all occurrence of a word ( use split() and join())
17.Read a string and replace all occurrence of a word with another (use split() and join())
18.Read a string and sort the words according to the length of the words.
19.Read list of names and print the sorted list in uppercase letters.
20.Remove all duplicate elements from a list.( refer example)
21.Read a string and remove all duplicate words.
22.Read a list and remove the duplicate elements completely. ( refer example)
23.Read a list and create a new list from this after removing all occurrences of a given element.
24.Remove the smallest and largest element from the list.
25.Students marks of an exam is stored as a list. Create two list of marks from this.( passed and failed, less than 50% is failed). Also find the number of passed and failed students.Average marks of passed students,Top scorer and lowest mark scorer.
26.write a python program to input a sentence and find the number of words in the sentence and print the words in uppercase.Also print the number of question marks(?), periods(.) and commas(,) present in the string. ( university question)
27.Write a python program to input a list of 'n' numbers.Calculate and display the sum of cubes each value in the list. ( university question)
28. Write a Python program to read a list consisting of integers, floating point numbers and strings. Separate them into different lists depending on the data(university question)
29.write a Python program to read list of positive integers and separate the prime and composite numbers
30.Find the mode of given set of numbers.(refer example programs)
31.Write a Python program to check whether a list contains a sublist.
Eg. Input 1: my_list = [3,4,5,2,7,8] , sub_list = [2,7] ( university question - refer example)
output 1: True
input 2: my_list = [3,4,5,2,7,8] , sub_list = [5,7]
output 2: False

Comments

Popular posts from this blog

Python For Machine Learning - CST 283 - KTU Minor Notes- Dr Binu V P

46.Classes and Objects in Python- Accessors and mutators

KTU Python for machine learning Sample Question Paper and Answer Key Dec 2020