If you want to master Python, then it is crucial to work on live python projects.
We are going to create a simple app that is going to collect marks from a user. It will sort these marks in ascending order from highest to lowest. Then it will drop the lowest two marks the user entered. At last, it’s going to show the highest marks the user got. Also, we will show an error message if the user is entering only two numbers.
The final output looks like this,
First, try to create the program by yourself before checking the source code. If you are not able to do create it, take reference from the source code.
Full source code:
print("Welcome to Marks Sorter App")
#get user input
marks = []
n=0
while(n<3):
n = int(input("How many marks you want to enter?"))
if (n<3):
print("Enter more than two marks!")
for i in range(1,n+1):
mark = int(input(f"\n Enter your {i} marks (0-100): "))
marks.append(mark)
print("\n Your marks are: ", str(marks))
#Sort the list from highest to lowest
marks.sort(reverse=True)
print("\nYour marks from highest to lowest: ", str(marks))
#Removing the lowest two marks
print("Removed marks are: ",marks.pop(),marks.pop())
#Printing the highest marks
print("Your highest mark is: ", str(marks[0]))
If you like this article and wish to connect with me follow me on Linkedin. Share your thoughts in the comments section below, what did you find interesting in this article!
Until next time, take care of yourself, your family, your extended family(neighbors), and your friends stay safe and healthy!
✨ Thanks ✨
Thanks for your blog, nice to read. Do not stop.