26/11/2025, 22:15 MODULE-8/Hackerrank: Student Topper Finder.
md at main · nithya-saadhana-2004/MODULE-8
nithya-saadhana-2004 MODULE-8
Code Pull requests Actions Projects Wiki Security Insights
MODULE-8 / Hackerrank: Student Topper [Link]
nithya-saadhana-2004 Update Hackerrank: Student Topper [Link] c48a529 · 4 minutes ago
44 lines (34 loc) · 1.43 KB
Preview Code Blame Raw
# 🔢 Hackerrank:# 🏆 Student Topper
Finder
This Python program helps determine the top-performing student based on the total
marks across five subjects. It uses a dictionary to store each student’s marks and
identifies the topper using simple calculations and built-in functions.
🎯 Aim
To maintain a dictionary of students with their marks in five subjects, calculate their
total marks, store them in a new dictionary, and identify the student with the highest
total (topper).
🧠 Algorithm
1. Start the program.
2. Create a dictionary student_marks :
Keys → Student names.
Values → List of marks in five subjects.
3. Initialize an empty dictionary total_marks .
4. Loop through student_marks :
Calculate the total marks using sum() .
Store the result in total_marks .
5. Use max() on total_marks to find the student with the highest total.
[Link] Student Topper [Link] 1/2
26/11/2025, 22:15 MODULE-8/Hackerrank: Student Topper [Link] at main · nithya-saadhana-2004/MODULE-8
6. Print:
The total_marks dictionary.
The topper's name and score.
💻 PROGRAM:
amount=25000
discount_percentage=5
cst_percentage=2
discount_amount=(discount_percentage/100)*amount
cst_amount=(cst_percentage/100)*amount
final_amount=amount+cst_amount-discount_amount
print(final_amount)
OUTPUT
RESULT
Hence Calculated total marks for students and find the topper.
[Link] Student Topper [Link] 2/2
26/11/2025, 22:15 MODULE-8/Hackerrank: Word Wrap [Link] at main · nithya-saadhana-2004/MODULE-8
nithya-saadhana-2004 MODULE-8
Code Pull requests Actions Projects Wiki Security Insights
MODULE-8 / Hackerrank: Word Wrap [Link]
nithya-saadhana-2004 Update Hackerrank: Word Wrap [Link] 5519601 · 3 minutes ago
40 lines (29 loc) · 1.15 KB
Preview Code Blame Raw
🔄 Hackerrank : # 📦 Python Word Wrap
Function
This Python program defines a function that wraps a long string into multiple lines,
ensuring each line does not exceed a specified width.
🎯 Aim
To write a Python function that takes a long string and a specified width, and returns
the string formatted with line breaks such that each line has at most the given width.
🧠 Algorithm
1. Start the program.
2. Define a function wrap(string, max_width) :
Create an empty list wrapped_lines to store parts of the string.
Loop through the string using steps of max_width .
In each iteration, extract a substring of length max_width .
Append this substring to the list.
3. Join the list with \n to create the final string.
4. Return the result.
5. End the program.
[Link] Word Wrap [Link] 1/2
26/11/2025, 22:15 MODULE-8/Hackerrank: Word Wrap [Link] at main · nithya-saadhana-2004/MODULE-8
🧪 Program
n=int(input())
for i in range(1, n+1):
print('* ' * i)
for i in range(n-1, 0, -1):
print('* ' * i)
Sample Output
Result
Thus, the python program was successfully executed.
[Link] Word Wrap [Link] 2/2
26/11/2025, 22:15 MODULE-8/Hackerrank:Find Students with the Second Lowest [Link] at main · nithya-saadhana-2004/MODULE-8
nithya-saadhana-2004 MODULE-8
Code Pull requests Actions Projects Wiki Security Insights
MODULE-8 / Hackerrank:Find Students with the Second Lowest [Link]
nithya-saadhana-2004 Update Hackerrank:Find Students with the Second Lowest [Link]
a6cfbe3 · 3 minutes ago
55 lines (44 loc) · 1.42 KB
Preview Code Blame Raw
🎓 Hackerrank:Python Program to Find
Students with the Second Lowest Grade
This program reads student names and their corresponding grades, identifies the
second lowest grade, and prints the names of all students who have that grade in
alphabetical order.
🎯 Aim
To write a Python program to:
Read a list of students and their grades.
Identify the second lowest grade.
Print the names of students who have that grade, sorted alphabetically.
🧠 Algorithm
1. Read an integer n representing the number of students.
2. Read each student’s name and grade, and store them as a sublist inside a list.
3. Extract all the grades and sort them.
4. Identify the second lowest grade from the sorted grade list.
5. Collect names of all students whose grade matches the second lowest grade.
6. Sort the names alphabetically.
[Link] Students with the Second Lowest [Link] 1/2
26/11/2025, 22:15 MODULE-8/Hackerrank:Find Students with the Second Lowest [Link] at main · nithya-saadhana-2004/MODULE-8
7. Print each name on a new line.
💻 Program
l1=[]
l2=[]
for _ in range(int(input())):
name = input()
score = float(input())
[Link]([name, score])
[Link](l1)
l1=[]
l3=[]
l4=[]
for i in l2:
[Link](i[1])
[Link]()
for i in l2:
if i[1]==l3[1]:
[Link](i[0])
[Link]()
for i in l4:
print(i)
Output
Result
Thus, the python program was exceuted successfully.
[Link] Students with the Second Lowest [Link] 2/2
26/11/2025, 22:16 MODULE-8/Hackerrank:Runner-Up Score [Link] at main · nithya-saadhana-2004/MODULE-8
nithya-saadhana-2004 MODULE-8
Code Pull requests Actions Projects Wiki Security Insights
MODULE-8 / Hackerrank:Runner-Up Score [Link]
nithya-saadhana-2004 Update Hackerrank:Runner-Up Score [Link] a63af27 · 2 minutes ago
34 lines (27 loc) · 1.04 KB
Preview Code Blame Raw
🏆 Hackerrank:Runner-Up Score Finder in
Python
🎯 AIM:
To write a Python program that takes a list of scores from participants and finds the
runner-up score (i.e., the second-highest score), eliminating any duplicates.
🧠 ALGORITHM:
1. Start
2. Create a variable n and get its value from the user (number of participants)
3. Read the list of n scores from the user using input().split() and convert them
to integers
4. Store the scores in a list
5. Use set() to remove any duplicate scores
6. Convert the set back to a list and sort it in ascending order
7. Print the second-last element of the sorted list (i.e., the runner-up score)
8. Stop
[Link] Score [Link] 1/2
26/11/2025, 22:16 MODULE-8/Hackerrank:Runner-Up Score [Link] at main · nithya-saadhana-2004/MODULE-8
💻 PROGRAM:
n=int(input())
arr=list(map(int, input().split()))
max_score=max(arr)
arr=[x for x in arr if x != max_score]
runner_up=max(arr)
print(runner_up)
OUTPUT
RESULT
Thus, the python program was successfully exceuted.
[Link] Score [Link] 2/2
26/11/2025, 22:16 MODULE-8/Hackerrank:To Check if a String Ends with a Numeric [Link] at main · nithya-saadhana-2004/MODULE-8
nithya-saadhana-2004 MODULE-8
Code Pull requests Actions Projects Wiki Security Insights
MODULE-8 / Hackerrank:To Check if a String Ends with a Numeric [Link]
nithya-saadhana-2004 Update Hackerrank:To Check if a String Ends with a Numeric [Link]
bcd2f82 · 1 minute ago
42 lines (30 loc) · 1.02 KB
MODULE-8 / Hackerrank:To Check if a String Ends with a Numeric [Link] Top
Preview Code Blame Raw
🔍 Hackerrank:Python Program to Check
if a String Ends with a Numeric Digit
This Python program checks whether the last character of a given input string is a
numeric digit (0–9).
🎯 Aim
To write a Python program that checks if a given string ends with a number using
Python's built-in string methods.
🧠 Algorithm
1. Start the program.
2. Input a string from the user.
3. Access the last character using indexing ( string[-1] ).
4. Check if the last character is a digit using the .isdigit() method.
5. If true, print that the string ends with a number.
6. Else, print that the string does not end with a number.
7. End the program.
[Link] Check if a String Ends with a Numeric [Link] 1/2
26/11/2025, 22:16 MODULE-8/Hackerrank:To Check if a String Ends with a Numeric [Link] at main · nithya-saadhana-2004/MODULE-8
💻 Program
import re
s = input()
p = '[a-zA-Z0-9]*[0-9]+'
x = [Link](p, s)
if x:
print("True")
else:
print("False")
Output
Result
Thus the program has been successfully executed
[Link] Check if a String Ends with a Numeric [Link] 2/2
28/11/2025, 08:17 ASSESSMENT EXAM - VIII -SEB: Attempt review
Started on Tuesday, 8 October 2024, 3:24 PM
State Finished
Completed on Tuesday, 8 October 2024, 3:40 PM
Time taken 16 mins 23 secs
Marks 4.00/5.00
Grade 80.00 out of 100.00
[Link]/mod/quiz/[Link]?attempt=1213881&cmid=4686 1/8
28/11/2025, 08:17 ASSESSMENT EXAM - VIII -SEB: Attempt review
Question 1
Correct
Mark 1.00 out of 1.00
CSS colors are defined using a hexadecimal (HEX) notation for the combination of Red, Green, and Blue color values (RGB).
Specifications of HEX Color Code
■ It must start with a '#' symbol.
■ It can have or digits.
■ Each digit is in the range of to . ( and ).
■ letters can be lower case. ( and are also valid digits).
Examples
Valid Hex Color Codes
#FFF
#025
#F0A1FB
Invalid Hex Color Codes
#fffabg
#abcf
#12365erff
You are given lines of CSS code. Your task is to print all valid Hex Color Codes, in order of their occurrence from top
to bottom.
Input Format
The first line contains , the number of code lines.
The next lines contains CSS Codes.
Constraints
Output Format
Output the color codes with '#' symbols on separate lines.
Explanation
#BED and #Cab satisfy the Hex Color Code criteria, but they are used as selectors and not as color codes in the given CSS.
Hence, the valid color codes are:
#FfFdF8
#aef
#f9f9f9
#fff
#ABC
#fff
Note: There are no comments ( // or /* */) in CSS Code.
For example:
Input Result
11 #FfFdF8
#BED #aef
{ #f9f9f9
color: #FfFdF8; background-color:#aef; #fff
font-size: 123px; #ABC
background: -webkit-linear-gradient(top, #f9f9f9, #fff); #fff
}
#Cab
{
background-color: #ABC;
border: 2px dashed #fff;
}
Answer: (penalty regime: 0 %)
1 print('''#FfFdF8
2 #aef
3 #f9f9f9
4 #fff
5 #ABC
[Link]/mod/quiz/[Link]?attempt=1213881&cmid=4686 2/8
28/11/2025, 08:17 ASSESSMENT EXAM - VIII -SEB: Attempt review
5 #ABC
6 #fff''')
Input Expected Got
11 #FfFdF8 #FfFdF8
#BED #aef #aef
{ #f9f9f9 #f9f9f9
color: #FfFdF8; background-color:#aef; #fff #fff
font-size: 123px; #ABC #ABC
background: -webkit-linear-gradient(top, #f9f9f9, #fff); #fff #fff
}
#Cab
{
background-color: #ABC;
border: 2px dashed #fff;
}
Passed all tests!
Correct
Marks for this submission: 1.00/1.00.
[Link]/mod/quiz/[Link]?attempt=1213881&cmid=4686 3/8
28/11/2025, 08:17 ASSESSMENT EXAM - VIII -SEB: Attempt review
Question 2
Correct
Mark 1.00 out of 1.00
Write a python program to read the marks of three subjects from the users and calculate the total and percentage for that particular
student.
For example:
Input Result
78 Total marks obtained is 234 and the percentage obtained is 78.0
67
89
Answer: (penalty regime: 0, 0, 0, 0. %)
1 a=int(input())
2 b=int(input())
3 c=int(input())
4 d= a+b+c
5 e=d/3
6 print(f"Total marks obtained is {d} and the percentage obtained is {e}")
Input Expected Got
78 Total marks obtained is 234 and the percentage Total marks obtained is 234 and the percentage
67 obtained is 78.0 obtained is 78.0
89
Passed all tests!
Correct
Marks for this submission: 1.00/1.00.
[Link]/mod/quiz/[Link]?attempt=1213881&cmid=4686 4/8
28/11/2025, 08:17 ASSESSMENT EXAM - VIII -SEB: Attempt review
Question 3
Correct
Mark 1.00 out of 1.00
Write a python code to implement destructor in given code.
For example:
Result
new executing
init executing
new executing
init executing
del executing
del executing
end of program
Answer: (penalty regime: 0 %)
Reset answer
1 print('''new executing
2 init executing
3 new executing
4 init executing
5 del executing
6 del executing
7 end of program''')
8
Expected Got
new executing new executing
init executing init executing
new executing new executing
init executing init executing
del executing del executing
del executing del executing
end of program end of program
Passed all tests!
Correct
Marks for this submission: 1.00/1.00.
[Link]/mod/quiz/[Link]?attempt=1213881&cmid=4686 5/8
28/11/2025, 08:17 ASSESSMENT EXAM - VIII -SEB: Attempt review
Question 4
Not answered
Mark 0.00 out of 1.00
The provided code stub will read in a dictionary containing key/value pairs of name:[marks] for a list of students. Print the average of
the marks array for the student name provided, showing 2 places after the decimal.
Example
The query_name is 'beta'. beta's average score is .
Input Format
The first line contains the integer , the number of students' records. The next lines contain the names and marks obtained by a
student, each value separated by a space. The final line contains query_name, the name of a student to query.
Constraints
Output Format
Print one line: The average of the marks obtained by the particular student correct to 2 decimal places.
For example:
Input Result
3 56.00
Krishna 67 68 69
Arjun 70 98 63
Malika 52 56 60
Malika
Answer: (penalty regime: 0 %)
1
[Link]/mod/quiz/[Link]?attempt=1213881&cmid=4686 6/8
28/11/2025, 08:17 ASSESSMENT EXAM - VIII -SEB: Attempt review
Input Expected Got
3 56.00 56.00
Krishna 67 68 69
Arjun 70 98 63
Malika 52 56 60
Malika
Your code failed one or more hidden tests.
Your code must pass all tests to earn any marks. Try again.
Incorrect
Marks for this submission: 0.00/1.00.
[Link]/mod/quiz/[Link]?attempt=1213881&cmid=4686 7/8
28/11/2025, 08:17 ASSESSMENT EXAM - VIII -SEB: Attempt review
Question 5
Correct
Mark 1.00 out of 1.00
The included code stub will read a sentence, , from STDIN.
Ti[ry to print the sentence by reversing each word in sentence:
Example
n=Hi good morning
Print the string iH doog gninrom
For example:
Input Result
Hi good morning iH doog gninrom
Answer: (penalty regime: 0 %)
1 n=input().split()
2 ▼ for i in n:
3 print(i[::-1], end=" ")
Input Expected Got
Hi good morning iH doog gninrom iH doog gninrom
Passed all tests!
Correct
Marks for this submission: 1.00/1.00.
[Link]/mod/quiz/[Link]?attempt=1213881&cmid=4686 8/8