0% found this document useful (0 votes)
6 views10 pages

Ai Project File

The document is an AI project file from Shalom Hills International School, created by Keshav Dagar, a student of class X-B. It includes a list of 15 programming projects, such as a Number Guessing Game, Armstrong Number Checker, and a Menu-Driven Calculator, along with their respective input and output code snippets. Each project demonstrates various programming concepts and functions in Python.

Uploaded by

Keshav Yadav
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views10 pages

Ai Project File

The document is an AI project file from Shalom Hills International School, created by Keshav Dagar, a student of class X-B. It includes a list of 15 programming projects, such as a Number Guessing Game, Armstrong Number Checker, and a Menu-Driven Calculator, along with their respective input and output code snippets. Each project demonstrates various programming concepts and functions in Python.

Uploaded by

Keshav Yadav
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

SHALOM HILLS INTERNATIONAL

SCHOOL
AI PROJECT FILE
NAME – KESHAV DAGAR
CLASS – X-B
INDEX
[Link] PROJECT NAME

1 Number Guessing Game

2 Armstrong Number

3 Menu-Driven Calculator

4 Palindrome String Checker

5 Character Frequency in a String

6 Largest and Smallest in a List

7 Count Vowels and Consonants

8 Marks Report (Dictionary Based)

9 Fibonacci Series

10 Sorting a List (Without Built-in Function)

11 Count Positive, Negative and Zero Numbers

12 Remove Duplicates from a List

13 Matrix Addition

14 Prime Numbers in a Range

15 Word Count in a Sentence


1 Number Guessing Game (Using Loops & Random)
INPUT-
import random

num = [Link](1, 50)


guess = -1
tries = 0

while guess != num:


try:
guess = int(input("Enter your guess (1–50): "))
tries += 1

if guess < num:


print("Too low!")
elif guess > num:
print("Too high!")
else:
print("Correct! You guessed in", tries, "tries")
except ValueError:
print("Please enter a valid number.")

OUTPUT-
2 Check Armstrong Number (3-digit)
INPUT-
n = int(input("Enter a number: "))
s = 0
temp = n

while temp > 0:


d = temp % 10
s += d ** 3
temp //= 10

if s == n:
print("Armstrong Number")
else:
print("Not Armstrong")

OUTPUT-

3 Menu-Driven Calculator (Using Functions)


INPUT-
def add(a,b): return a+b
def sub(a,b): return a-b
def mul(a,b): return a*b
def div(a,b): return a/b

print("[Link] [Link] [Link] [Link]")


ch = int(input("Enter choice: "))
a = float(input("Enter first number: "))
b = float(input("Enter second number: "))

if ch == 1: print(add(a,b))
elif ch == 2: print(sub(a,b))
elif ch == 3: print(mul(a,b))
elif ch == 4: print(div(a,b))
else: print("Invalid choice")
OUTPUT-
4 Palindrome String Checker
INPUT-
s = input("Enter a string: ")
if s == s[::-1]:
print("Palindrome")
else:
print("Not Palindrome")
OUTPUT-

5 Frequency of Each Character in a String


INPUT-
s = input("Enter a string: ")
freq = {}

for ch in s:
freq[ch] = [Link](ch, 0) + 1

print("Character Frequency:", freq)

OUTPUT-
6 Largest & Smallest in a List
INPUT-
lst = list(map(int, input("Enter numbers: ").split()))
print("Largest =", max(lst))
print("Smallest =", min(lst))

OUTPUT-

7 Count Vowels & Consonants


INPUT-
s = input("Enter a word: ").lower()
vowels = "aeiou"
v = c = 0

for ch in s:
if [Link]():
if ch in vowels: v += 1
else: c += 1

print("Vowels:", v)
print("Consonants:", c)
OUTPUT-
8 Simple Marks Report (Dictionary)
INPUT-
marks = {}
n = int(input("Enter number of subjects: "))

for i in range(n):
sub = input("Subject name: ")
m = int(input("Marks: "))
marks[sub] = m

print("Report Card:", marks)


print("Total =", sum([Link]()))
print("Percentage =", sum([Link]()) / n)
OUTPUT-

9 Fibonacci Series (n Terms)


INPUT-
n = int(input("Enter terms: "))
a, b = 0, 1

for i in range(n):
print(a, end=" ")
a, b = b, a + b
OUTPUT-
10 Sort a List Without Built-in Sort
INPUT-
lst = list(map(int, input("Enter numbers: ").split()))

for i in range(len(lst)):
for j in range(i+1, len(lst)):
if lst[i] > lst[j]:
lst[i], lst[j] = lst[j], lst[i]

print("Sorted List:", lst)


OUTPUT-

11Count Positive, Negative & Zero Values


INPUT-
lst = list(map(int, input("Enter numbers: ").split()))
p = n = z = 0

for x in lst:
if x > 0: p += 1
elif x < 0: n += 1
else: z += 1

print("Positive:", p, "Negative:", n, "Zero:", z)


OUTPUT-
12 Remove Duplicates from a List
INPUT-
lst = list(map(int, input("Enter numbers: ").split()))
unique = []

for x in lst:
if x not in unique:
[Link](x)

print("After removing duplicates:", unique)


OUTPUT-

13 Matrix Addition (2×2 or 3×3)


INPUT-
m1 = [[1,2],[3,4]]
m2 = [[5,6],[7,8]]
res = []

for i in range(len(m1)):
row = []
for j in range(len(m1[0])):
[Link](m1[i][j] + m2[i][j])
[Link](row)

print("Result Matrix =", res)


OUTPUT-
14 Display Prime Numbers in a Range
INPUT-
start = int(input("Start: "))
end = int(input("End: "))

for n in range(start, end+1):


if n > 1:
for i in range(2, int(n**0.5)+1):
if n % i == 0:
break
else:
print(n, end=" ")
OUTPUT-

15 Word Count in a Sentence


INPUT-
s = input("Enter a sentence: ")
words = [Link]()
print("Total words =", len(words))
OUTPUT-

You might also like