1.
a) Write a Python program to find the highest average of two out of three test
scores entered by the user.
score1 = float(input("Enter first test score: "))
score2 = float(input("Enter second test score: "))
score3 = float(input("Enter third test score: "))
scores = [score1, score2, score3]
scores.remove(min(scores))
average = sum(scores) / 2
print("The highest average of two scores is:", average)
Output:
Enter first test score: 35.2
Enter second test score: 33.8
Enter third test score: 98.7
The highest average of two scores is: 66.95
b) Develop a Python program to check if a given number is a palindrome and
count the occurrences of each digit.
number = input("Enter a number: ")
# Check if palindrome
if number == number[::-1]:
print("The number is a palindrome.")
else:
print("The number is not a palindrome.")
# Count digit occurrences
print("Digit occurrences:")
for digit in "0123456789":
count = number.count(digit)
if count > 0:
print(f"{digit}: {count}")
output:
1. Enter a number: 12321
The number is a palindrome.
Digit occurrences:
1: 2
2: 2
3: 1
2. Enter a number: 12345436
The number is not a palindrome.
Digit occurrences:
1: 1
2: 1
3: 2
4: 2
5: 1
6: 1