1. Check Eligibility to Vote 5.
Calculate Average Marks of
Subjects
python
CopyEdit python
age = int(input("Enter your age: ")) CopyEdit
if age >= 18: marks = [78, 88, 92, 85, 90]
print("You are eligible to vote.") avg = sum(marks) / len(marks)
else: print("Average marks:", avg)
print("You are not eligible to
vote.")
6. Reverse Each Word in a
2. Sum of Even Numbers from 1 to Sentence
100
python
python CopyEdit
CopyEdit sentence = input("Enter a sentence:
total = 0 ")
for i in range(2, 101, 2): words = sentence.split()
total += i reversed_words = [word[::-1] for
print("Sum of even numbers from 1 word in words]
to 100 is:", total) print(" ".join(reversed_words))
3. Check Whether a Number is 7. Check Palindrome Word
Prime
python
python CopyEdit
CopyEdit word = input("Enter a word: ")
num = int(input("Enter a number: print("Palindrome" if word ==
")) word[::-1] else "Not a palindrome")
is_prime = True
if num < 2: 8. Rock-Paper-Scissors Game
is_prime = False
else: python
for i in range(2, CopyEdit
int(num**0.5)+1): import random
if num % i == 0: options = ['rock', 'paper', 'scissors']
is_prime = False user = input("Choose
break rock/paper/scissors: ")
print("Prime" if is_prime else "Not comp = random.choice(options)
Prime") print("Computer chose:", comp)
if user == comp:
print("Draw")
4. Count Occurrences of Each elif (user == "rock" and comp ==
Character in a String "scissors") or \
(user == "paper" and comp ==
python "rock") or \
CopyEdit (user == "scissors" and comp
text = input("Enter a string: ") == "paper"):
freq = {} print("You win!")
for char in text: else:
freq[char] = freq.get(char, 0) + 1 print("Computer wins!")
print(freq)