Skip to content

Commit b9119fb

Browse files
committed
15-11-2025
1 parent 4533934 commit b9119fb

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

Extract_alphabetic.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Write a python function that takes a string as input and returns a new string containing only the alphabetic characters from the original string.
2+
3+
def extract_alphabetic(input_string):
4+
result = ''.join(char for char in input_string if char.isalpha())
5+
return result
6+
7+
# Test the function
8+
if __name__ == "__main__":
9+
test_string = "Hello123 World!@#"
10+
print(extract_alphabetic(test_string)) # Output: HelloWorld
11+

Score_status.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Write a program in python l[p through the list and classify each score and "pass" or "fail " (passing marki s 50 ).
2+
# Store the result in a new list of dictionaries with keys :- "Score " and "Status ".
3+
4+
def classify_scores(scores):
5+
# New list to store results
6+
result = []
7+
# Loop through each score
8+
for score in scores:
9+
# Classify as pass or fail
10+
status = "pass" if score >= 50 else "fail"
11+
# Create dictionary
12+
entry = {"Score": score, "Status": status}
13+
# Append to result list
14+
result.append(entry)
15+
return result
16+
17+
# Test cases
18+
test_cases = [
19+
[45, 55, 30, 70, 49, 60, 25, 80], # Original
20+
[50], # Exactly 50
21+
[-10, 0, 49.9], # Negative, zero, below 50 float
22+
[100, 150], # High scores
23+
[49.5, 50.5], # Floats
24+
[], # Empty list
25+
[50, 50, 49, 49] # Duplicates
26+
]
27+
28+
for i, scores in enumerate(test_cases):
29+
print(f"Test case {i+1}: {scores}")
30+
result = classify_scores(scores)
31+
print(result)
32+
print()

0 commit comments

Comments
 (0)