Search

# Python Top Practice Examples | Python Programming Help - 1 -

Given a sorted List, remove the duplicates in-place such that each element appears only once and returns the new length.

Example 1:

Given List1 = [1, 1, 2],

Your function should return length = 2, with the first two elements of List1 being 1 and 2 respectively.

Example 2:

Given List2 = [0, 0,1, 1, 1, 2, 2, 3, 3, 4],

Your function should return length = 5, with the first five elements of List2 being modified to 0, 1, 2, 3, and 4 respectively.

- 2 -

2. Write a program that will take the marks (for three assessments Quiz1 (20%), Quiz2(30% and Final(50%)) of all the students of a unit as input and stores all the detail in a list. Your program should have the following features and constraints:

• Check the input validity

• Compute the total marks and letter grades. Use the Murdoch university grade conversion table to calculate the letter grade.

• Keep taking the input unless a negative or zero is given as the input for student ID

• Save the data in the following format: [st_ID, Q1_mark, Q2_mark, Final_mark, Total, Letter grade]

• Display the whole list.

Output:

A typical input-output might be as follows:

Student ID:1001

Enter Q1: 20

Enter Q2: 25

Enter Final: 40

Student ID:1002

Enter Q1: 12

Enter Q2: 2.5

Enter Final: 45

Student ID:1003

Enter Q1: 20

Enter Q2: 30

Enter Final: 32

Student ID:0

[[1001, 20.0, 25.0, 40.0, 85.0, ‘HD’], [1002, 12.0, 2.5, 45.0, 59.5, ‘P’],

[1003, 20.0, 30.0, 32.0, 82.0, ‘D’]]

Note: This output format may not look the same as the format asked.

3. [Continuation of question 2] Show the following statistics:

• Average, highest and lowest mark

• The ID of all the students who got the highest mark

• The ID of all the students who got the lowest mark

• Total number of students failed in the unit (assuming 50% is the pass mark)