Showing posts with label Lists. Show all posts
Showing posts with label Lists. Show all posts

PYTHON ASSIGNMENT 5: LISTS



Write a program to read a set of numbers from a user and store in a list. Eliminate duplicate elements.

Given a list of N numbers, read the element to search in the list. Display the number of occurrences of the element with its position.

Anagrams. Given a list of words display the sets of anagrams.

Given a list of integers, create a new list with cumulative sum; that is a new list where the ith element is the sum of the first i elements from the original list. For example, the cumulative sum of [4, 3, 6] is [4, 7, 13].

Create a nested list containing student details (Roll number, name and 3 marks). Print the roll number, name, total and average marks of each student. 

Given two lists that are sorted in ascending order, write a program to merge the lists into a single list that contains every item from both lists in sorted order.


Matrix

Addition, subtraction and multiplication of matrices.

Transpose of a matrix.

Sum of diagonal elements of a matrix.

Largest, smallest element in matrix.

Find maximum in a list of numbers - Lists

# Find maximum in a list of numbers

print("\n\nFind maximum in a list of numbers")

no_of_terms = int(input("Enter number of terms : "))
list1 = []

for counter in range(0,no_of_terms,1):
    num = int(input("Enter number : "))
    list1.append(num)
   
print("Given list of numbers :", list1)
print("Maximum value in the list of numbers is", max(list1))