[go: up one dir, main page]

100% found this document useful (1 vote)
86 views25 pages

Project Ai

The document is a project report on Python programming submitted by Shashwat Jaiswal for the ICSE 2026 examination as part of a Robotics and AI course. It includes various Python programs demonstrating basic programming concepts such as checking even/odd numbers, calculating simple interest, and determining triangle feasibility based on side lengths. Each program is accompanied by algorithms, variable data types, and sample outputs.
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
100% found this document useful (1 vote)
86 views25 pages

Project Ai

The document is a project report on Python programming submitted by Shashwat Jaiswal for the ICSE 2026 examination as part of a Robotics and AI course. It includes various Python programs demonstrating basic programming concepts such as checking even/odd numbers, calculating simple interest, and determining triangle feasibility based on side lengths. Each program is accompanied by algorithms, variable data types, and sample outputs.
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
You are on page 1/ 25

A PROJECT REPORT ON

PYTHON PROGRAMMING
FOR ICSE 2026 EXAMINATION

[AS A PART OF ROBOTICS AND AI COURSE]

SUBMITTED BY: SHASHWAT JAISWAL

NAME: SHASHWAT JAISWAL


ROLL NO: 30

[UNDER THE GUIDANCE OF – SUPRIYA JHA


ACKNOWLEDGEMENT

I undertook these programs as a part of my class 9 Robotics and AI. I


have tried to apply my best knowledge and experience gained during
the class work experience.
I would like to extend my sincere thanks and gratitude to my teacher
Supriya Jha, for giving me her valuable time and moral support
to develop this project.
TABLE OF CONTENTS
S. NO TOPIC PAGE NO:
1 intro 1
2 acknowledgement 2
3 Table of content 3
4 Program 1 and 2 4
5 Program 2 and 3 5
6 Program 3 6
7 Program 4 7
8 Program 5 8
9 Program 5 9
10 Program 6 10
11 Program 7 11
12 Program 8 12
13 Program 8 13
14 Program 10 14
15 Program 10 15
16 Program 10 16
17 Program 11 17
18 Program 12 18
19 Program 12 19
20 Program 13 20
21 Program 14 21
22 Program 15 22
23 Program 15 23
24 Program 15 24 and 25
PROGRAM 1
Write a script to input a number and check whether it is even or odd, and then display an
appropriate message.

number = int(input("Enter a number: "))

if number % 2 == 0:
#this is to check wheteher a number is divisible by 0 or not
print("The number is even.")
#if it is divisible by 2 then it will print the number as even
else:
#if it is not divisible by 2 then it will print the number as odd
print("The number is odd.")

VDT:
variable datatype purpose
number Int or integer Stores the number entered by
the user.

Algorithm:
1. Input a number from the user.
2. Check if the number is divisible by 2 without any remainder.
3. If yes, print "The number is even", otherwise print "The number is odd".
Output:
 For example, if the user inputs 7, the output will be "The number is odd."
 This program effectively determines whether a given number is even or odd and provides the
corresponding message.

PROGRAM 2
Write a script to input a number. If the number is even, print its square, otherwise print
its cube.
number = int(input("Enter a number: "))
if number % 2 == 0:
#this is to check whether the number is divisible by 2 or not
print("Square of", number, "is", number**2)
#if it is divisible by 2 then print the sqaure of the number
else:
#and if it is not divisible by 2 then print the cube of the number
print("Cube of", number, "is", number**3)
VDT:
variable datatype purpose
number Int or integer Stores the number entered by
the user.

Algorithm:
1. Input a number from the user.
2. Check if the number is divisible by 2 without any remainder.
3. If yes, print the square of the number, otherwise print the cube of the number.

Output:
 For instance, if the user inputs 5, the output will be "Cube of 5 is 125."
 This program provides the square of an even number and the cube of an odd number, based on
user input.

PROGRAM 3
Write a script which inputs two numbers from the user and checks if the first number is
divisible by the second or not. The script should then display an appropriate message.

num1 = int(input("Enter first number: "))


num2 = int(input("Enter second number: "))

if num2 == 0:
print("Cannot divide by zero.")
#as no number can be divided by zero so this print line will show that the 2nd number cannot
divide the 1st number(as 2nd number is 0)
elif num1 % num2 == 0:
print(num1, "is divisible by", num2)
#if number 1 is divisible by the 2nd number then it will print the above statement.
else:
print(num1, "is not divisible by", num2)
#and if the 1st number is not divisible by the 2nd number then it will the the above statement.

VDT:
variable datatype purpose
num1 Int or integer Stores the number entered by
the user.
num2 Int or integer Stores the number entered by
the user.

ALGORITHM:
1. Prompt the user to enter the first number.
2. Read the input and convert it to an integer.
3. Prompt the user to enter the second number.
4. Read the input and convert it to an integer.
5. Check if the second number is zero:
 If it is zero, print a message indicating that division by zero is not allowed.
6. Otherwise, check if the first number is divisible by the second number:
 If it is divisible, print a message indicating that the first number is divisible by the second
number.
 If it is not divisible, print a message indicating that the first number is not divisible by the second
number.
OUTPUT:
Case 1: Divisible

 Enter the first number: 10


 Enter the second number: 2
 10 is divisible by 2.

Case 2: Not Divisible

 Enter the first number: 10


 Enter the second number: 3
 10 is not divisible by 3.

Case 3: Division by Zero

 Enter the first number: 10


 Enter the second number: 0
 The second number cannot be zero
PROGRAM 4:
Gunjan wants to write a script to input the number of students in a class and perform some
processing. She knows that sometimes the user may enter a negative number for the number of
students. In such a case, she wants to take the positive value of the number (e.g., if a user enters -35,
she wants to take 35). Help Gunjan by writing the part of the script which inputs the number of
students in a class and converts it into a positive number if it is negative.

PROGRAM:
# Input the number of students
num_students = int(input("Enter the number of students in the class: "))

# Convert to positive if the number is negative


if num_students < 0:
num_students = abs(num_students)

# Output the (non-negative) number of students


print("The number of students in the class is:", num_students)

VDT:

Variable Datatype purpose

num_students int Stores the number of students


inputted by the user
(converted to a positive
number if negative)

ALGORITHM:
1. Prompt the user to enter the number of students in the class.
2. Read the input and convert it to an integer.
3. Check if the input number is negative.
 If it is negative, convert the number to its positive value using the abs() function.
4. Print the non-negative number of students.

OUTPUT:
Case 1: Positive Input

 Enter the number of students in the class: 25


 The number of students in the class is: 25
Case 2: Negative Input

 Enter the number of students in the class: -35


 The number of students in the class is: 35

PROGRAM 5:

Write a script to input 10 numbers and then display the smallest number entered. If the
smallest number is an integer, then find the sum of its digits, otherwise display the message
“smallest number is not an integer”.

# Initialize an empty list to hold the numbers


numbers = [0] * 10

# Collect 10 numbers from the user


for i in range(10):
number = float(input(f"Enter number {i+1}: "))
numbers[i] = number

# Find the smallest number in the list


smallest_number = min(numbers)
print(f"The smallest number entered is: {smallest_number}")

# Check if the smallest number is an integer


if smallest_number == int(smallest_number):
integer_part = int(smallest_number)

# Calculate the sum of the digits of the integer part


digit_sum = sum(int(digit) for digit in str(integer_part))
print(f"The sum of the digits of the smallest integer {integer_part} is: {digit_sum}")
else:
print("Smallest number is not an integer")

VDT:
VARIABLE DATA TYPE PURPOSE
numbers List[float] To store the 10 numbers
entered by the user
i int Loop counter to iterate
through 10 numbers input
number float Temporary variable to store
each number entered by the
user
smallest_number float To store the smallest number
from the list of numbers
integer_part int To store the integer part of the
smallest number if it is an
integer
digit_sum int To store the sum of the digits
of the smallest integer

ALGORITHM:

 Collect and Store Input Numbers:

 Initialize a list numbers with 10 elements.


 Loop 10 times to prompt the user to enter a number and store each number in the list.

 Find and Analyze the Smallest Number:

 Use the min() function to find the smallest number in the list.
 Check if the smallest number is an integer. If it is, calculate the sum of its digits and print
the result. If it is not, print a message indicating that the smallest number is not an
integer.

OUTPUT:

Understood! Here’s a concise outline of the script’s output in bullet points:


Smallest number is not an integer:
Example: [3.5, 2.1, 5.6, 1.8, 4.4, 0.7, 2.9, 3.3, 1.1, 1.9]
Output:
The smallest number entered is: 0.7
Smallest number is not an integer
Smallest number is an integer:
Example: [8, 2, 4, 1, 7, 5, 3, 6, 9, 0]
Output:
The smallest number entered is: 0
The sum of the digits of the smallest integer 0 is: 0
Smallest number is a positive integer with multiple digits:
Example: [12, 7, 3, 25, 8, 14, 5, 9, 6, 11]
Output:
The smallest number entered is: 3
The sum of the digits of the smallest integer 3 is: 3

PROGRAM 6:

Write a script to input principal, time and calculate simple interest. If time is more than 10
years, calculate simple interest at the rate of 8% p.a., otherwise calculate it at the rate of
12% p.a.

principal=int(input("enter the principal"))#inputs the principal from the user


time=int(input("write the years in number"))
if time>10:
si= (principal*8*time)/100
print("the simple interest is",si)#if time is greater than 10 it will print si
else:
sii=(principal*12*time)/100
print("the simple interest is",sii)#if time is not greater than 10 it will print sii

VDT:
Variable Data Type Purpose

principal Int To store the principal amount


input by the user
time Int To store the number of years
input by the user
si Float To calculate and store the
simple interest if time > 10
sii float To calculate and store the
simple interest if time ≤ 10

ALGORITHM:

 Input Principal and Time:

 Prompt the user to input the principal amount and the number of years.

 Calculate Simple Interest:

 If the number of years (time) is greater than 10:


o Calculate simple interest using an interest rate of 8%.
o Print the calculated simple interest.
 Otherwise:
o Calculate simple interest using an interest rate of 12%.
o Print the calculated simple interest.
OUTPUT:

 If time is greater than 10:

 Example: Principal is 1000 and time is 12.


 Output:
o The simple interest is 960.0

 If time is 10 or less:

 Example: Principal is 1000 and time is 5.


 Output:
o The simple interest is 600.0

PROGRAM 7:

Write a script to input three numbers and find whether they form the three sides of a
triangle.
# Input three numbers from the user representing the sides of a triangle
a = float(input("Enter the first side length: "))
b = float(input("Enter the second side length: "))
c = float(input("Enter the third side length: "))

# Check if the sum of any two sides is greater than the third side
if a + b > c and a + c > b and b + c > a:
# If all conditions are met, the sides can form a triangle
print("The numbers can form a triangle.")
else:
# If any condition is not met, the sides cannot form a triangle
print("The numbers cannot form a triangle.")

VDT:
variable Data type Purpose
a float To store the length of the first
side of the triangle.
b float To store the length of the
second side of the triangle.
c float To store the length of the third
side of the triangle.
ALGORITHM:

 Input Three Side Lengths:

 Read the values of the sides a, b, and c.

 Check Triangle Inequality:

 Verify if a + b > c, a + c > b, and b + c > a.

 Output the Result:

 Print "The numbers can form a triangle" if all conditions are met.
 Otherwise, print "The numbers cannot form a triangle."

OUTPUT:

 When the numbers can form a triangle:

 Example: If the side lengths are 3, 4, and 5.


 Output:
o "The numbers can form a triangle."

 When the numbers cannot form a triangle:

 Example: If the side lengths are 1, 2, and 3.


 Output:
o "The numbers cannot form a triangle."

 When the numbers form a degenerate triangle:

 Example: If the side lengths are 2, 2, and 4.


 Output:
o "The numbers cannot form a triangle."

PROGRAM 8:

Write a script to input the coefficients (a,b,c) of a quadratic equation ax^2+bx+c=0, and
find the nature of its roots (Real and equal roots, Real and unequal roots, or Complex
roots).

# Input coefficients from the user


a = float(input("Enter coefficient a: "))
b = float(input("Enter coefficient b: "))
c = float(input("Enter coefficient c: "))
# Calculate the discriminant
discriminant = b * b - 4 * a * c

# Determine the nature of the roots based on the discriminant


if discriminant > 0:
print("The roots are real and unequal.")
elif discriminant == 0:
print("The roots are real and equal.")
else:
print("The roots are complex.")

VDT:
Variable Data Type Purpose
a float To store the coefficient of x^2
in the quadratic equation.
b float To store the coefficient of xxx
in the quadratic equation.
c float To store the constant term in
the quadratic equation.
discriminant float To calculate and store the
value of b2−4acb^2 -
4acb2−4ac which determines
the nature of the roots.

ALGORITHM:

 Input Coefficients:

 Prompts the user to enter the coefficients aaa, bbb, and ccc of the quadratic equation.

 Calculate Discriminant:

 Computes the discriminant using the formula discriminant=b2−4ac\text{discriminant} =


b^2 - 4acdiscriminant=b2−4ac.

 Determine Root Nature:

 Real and Unequal: If the discriminant is greater than 0.


 Real and Equal: If the discriminant is equal to 0.
 Complex: If the discriminant is less than 0.

OUTPUT:

 Real and Unequal Roots:


 Example input: a = 1, b = 5, c = 6
 Output:
o The roots are real and unequal.

 Real and Equal Roots:

 Example input: a = 1, b = 2, c = 1
 Output:
o The roots are real and equal.

 Complex Roots:

 Example input: a = 1, b = 2, c = 5
 Output:
o The roots are complex.

EXTRA INFO:
The discriminant is the part of the quadratic formula underneath the square root symbol: b²-4ac.
The discriminant tells us whether there are two solutions, one solution, or no solutions.

PROGRAM 10:
Write a menu driven script to calculate the total surface area and volume of a cube,
cuboid, or sphere depending upon the user's choice.
# Value of pi
pi = 3.141592653589793

while True:
print("\nMenu:")
print("1. Cube")
print("2. Cuboid")
print("3. Sphere")
print("4. Exit")

choice = input("Enter your choice (1/2/3/4): ")

if choice == '1':
side = float(input("Enter the side length of the cube: "))
surface_area = 6 * (side ** 2)
volume = side ** 3
print(f"Surface Area of the cube: {surface_area}")
print(f"Volume of the cube: {volume}")

elif choice == '2':


length = float(input("Enter the length of the cuboid: "))
width = float(input("Enter the width of the cuboid: "))
height = float(input("Enter the height of the cuboid: "))
surface_area = 2 * (length * width + width * height + length * height)
volume = length * width * height
print(f"Surface Area of the cuboid: {surface_area}")
print(f"Volume of the cuboid: {volume}")

elif choice == '3':


radius = float(input("Enter the radius of the sphere: "))
surface_area = 4 * pi * (radius ** 2)
volume = (4/3) * pi * (radius ** 3)
print(f"Surface Area of the sphere: {surface_area}")
print(f"Volume of the sphere: {volume}")

elif choice == '4':


print("Exiting...")
break

else:
print("Invalid choice. Please enter a valid option.")

VDT:
Variable Data Type Purpose
pi Float To store the value of pi (π)
choice str To store the user's choice from
the menu
side Float To store the side length of the
cube
length Float Stores the length of the
cuboid.
width Float Stores the width of the cuboid.
height Float Stores the height of the
cuboid.
radius Float Stores the radius of the sphere.
surface_area Float Stores the calculated surface
area of the shape.
volume Float Stores the calculated volume
of the shape.

ALGORITHM:

Algorithm

1. Initialize Pi:
o Set pi to 3.141592653589793.
2. Display Menu and Get User Choice:
o Print the menu options.
o Read the user's choice.
3. Process User Choice:
o If Choice is 1 (Cube):
 Prompt user for the side length.
 Calculate the surface area and volume of the cube.
 Display the surface area and volume.
o If Choice is 2 (Cuboid):
 Prompt user for the length, width, and height.
 Calculate the surface area and volume of the cuboid.
 Display the surface area and volume.
o If Choice is 3 (Sphere):
 Prompt user for the radius.
 Calculate the surface area and volume of the sphere.
 Display the surface area and volume.
o If Choice is 4 (Exit):
 Print exiting message.
 Break the loop and exit the program.
o If Choice is Invalid:
 Display an error message and prompt user to enter a valid option.

OUTPUT:
Example 1: Cube

 Input:
o Side length: 4
 Output:
o Surface Area of the cube: 96.0
o Volume of the cube: 64.0

Example 2: Cuboid

 Input:
o Length: 3
o Width: 4
o Height: 5
 Output:
o Surface Area of the cuboid: 94.0
o Volume of the cuboid: 60.0

Example 3: Sphere

 Input:
o Radius: 5
 Output:
o Surface Area of the sphere: 314.1592653589793
o Volume of the sphere: 523.5987755982989
PROGRAM 11:

Write a script to input four numbers and find the largest of these without using built-
infunction max().

# Input four numbers from the user


num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
num3 = float(input("Enter the third number: "))
num4 = float(input("Enter the fourth number: "))

# Find the largest number without using max()


largest = num1

if num2 > largest:


largest = num2

if num3 > largest:


largest = num3

if num4 > largest:


largest = num4

# Output the largest number


print(f"The largest number is: {largest}")

VDT:

Variable Data Type Purpose


num1 Float Stores the first input number
num2 Float Stores the second input
number
num3 Float Stores the third input number
num4 Float Stores the fourth input number
largest float Stores the current largest
number

ALGORITHM:

 Input Numbers:
Prompt the user to enter four numbers and store them in num1, num2, num3, and num4.
 Initialize Largest:
Set largest to num1.
 Compare Numbers:
Compare largest with num2, num3, and num4 sequentially.
Update largest if any of these numbers are greater.
 Output:Print the largest number.
OUTPUT:
Example 1:
Input:
num1: 5
num2: 8
num3: 3
num4: 7
Output:
The largest number is: 8
Example 2:
Input:
num1: -1
num2: -5
num3: -3
num4: -2
Output:
The largest number is: -1

PROGRAM 12:
12. Write a script which inputs three numbers from the user and displays these numbers in
ascending order.

# Input three numbers from the user


num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
num3 = float(input("Enter the third number: "))

# Sort the numbers manually


if num1 > num2:
num1, num2 = num2, num1
if num2 > num3:
num2, num3 = num3, num2
if num1 > num2:
num1, num2 = num2, num1

# Output the numbers in ascending order


print(f"The numbers in ascending order are: {num1}, {num2}, {num3}")

VDT:
ALGORITM:

 Input Numbers:

 Prompt the user to enter three numbers.


 Store these numbers in variables num1, num2, and num3.

 Sort the Numbers Manually:

 Compare num1 and num2. If num1 is greater than num2, swap them.
 Compare num2 and num3. If num2 is greater than num3, swap them.
 Compare num1 and num2 again. If num1 is greater than num2, swap them.

OUTPUT:
Example 1:
Input:
num1: 5
num2: 1
num3: 3
Output:
The numbers in ascending order are: 1.0, 3.0, 5.0
Example 2:
Input:
num1: -2
num2: 0
num3: -5
Output:
The numbers in ascending order are: -5.0, -2.0, 0.0
PROGRAM 13:
Write a program to find the sum of first n natural numbers, where n is to be input from
the user.

# Input the value of n from the user


n = int(input("Enter the number of natural numbers to sum: "))

# Initialize the sum to 0


sum_of_natural_numbers = 0

# Loop through the first n natural numbers and calculate the sum
for i in range(1, n + 1):
sum_of_natural_numbers += i

# Output the result


print(f"The sum of the first {n} natural numbers is: {sum_of_natural_numbers}")

VDT:
Variable Data Type Purpose
n Int Stores the number of natural
numbers to sum
sum_of_natural_numbers Int Stores the accumulated sum of
the first n natural numbers
i int Loop counter to iterate
through numbers 1 to n

ALGORITM:
 Input:
Prompt the user to enter a number nnn.
Read the input and store it in the variable n.
 Initialize Sum:
Set sum_of_natural_numbers to 0.
 Loop and Accumulate:
Use a for loop to iterate from 1 to nnn.
Add each number to sum_of_natural_numbers during each iteration.
 Output:
Print the result showing the sum of the first nnn natural numbers.
OUTPUT:
Example 1:
Input:
n: 5
Output:
The sum of the first 5 natural numbers is: 15
Example 2:
Input:
n: 10
Output:The sum of the first 10 natural numbers is: 55
PROGRAM 14:
Write a program to input a number and check whether it is palindrome or not.
# Input the number from the user
number = input("Enter a number: ")

# Check if the number is a palindrome


if number == number[::-1]:
print(f"The number {number} is a palindrome.")
else:
print(f"The number {number} is not a palindrome.")

VDT:
Variable Data Type Purpose

number str Stores the input number as a


string

ALGORITHM:

 Input:

 Prompt the user to enter a number.


 Read the input and store it in the variable number.

 Check Palindrome:

 Compare the number with its reverse (achieved using slicing number[::-1]).

 Output:

 If the number is the same as its reverse, print that it is a palindrome.


 Otherwise, print that it is not a palindrome.

OUTPUT:
Example 1:
Input:
number: 121
Output:
The number 121 is a palindrome.
Example 2:
Input:
number: 123
Output:
The number 123 is not a palindrome.
PROGRAM 15:
import math

while True:
# Display the menu
print("\nMenu:")
print("1. Cube")
print("2. Cuboid")
print("3. Sphere")
print("4. Exit")

# Get the user's choice


choice = int(input("Enter your choice (1-4): "))

if choice == 1:
# Calculate for Cube
side = float(input("Enter the side length of the cube: "))
surface_area = 6 * side ** 2
volume = side ** 3
print(f"Total surface area of the cube: {surface_area}")
print(f"Volume of the cube: {volume}")

elif choice == 2:
# Calculate for Cuboid
length = float(input("Enter the length of the cuboid: "))
width = float(input("Enter the width of the cuboid: "))
height = float(input("Enter the height of the cuboid: "))
surface_area = 2 * (length * width + width * height + height * length)
volume = length * width * height
print(f"Total surface area of the cuboid: {surface_area}")
print(f"Volume of the cuboid: {volume}")

elif choice == 3:
# Calculate for Sphere
radius = float(input("Enter the radius of the sphere: "))
surface_area = 4 * math.pi * radius ** 2
volume = (4/3) * math.pi * radius ** 3
print(f"Total surface area of the sphere: {surface_area}")
print(f"Volume of the sphere: {volume}")

elif choice == 4:
# Exit the program
print("Exiting the program.")
break

else: print("Invalid choice! Please enter a number between 1 and 4.")


VDT:
Variable Data Type Purpose

Stores the
user's
menu
choice int choice

Stores the
side
length of
side float the cube

Stores the
length of
the
length float cuboid

Stores the
width of
the
width float cuboid

Stores the
height of
the
height float cuboid

Stores the
radius of
the
radius float sphere

Stores the
calculated
surface_ surface
area float area

Stores the
calculated
volume float volume
ALGORITHM:

 Display Menu:

 Show a menu with options for calculating the surface area and volume of a cube, cuboid,
or sphere, and an option to exit.

 Get User Choice:

 Prompt the user to enter their choice (1-4).

 Calculate Based on Choice:

 If the choice is 1, prompt the user for the side length of the cube and calculate its surface
area and volume.
 If the choice is 2, prompt the user for the length, width, and height of the cuboid and
calculate its surface area and volume.
 If the choice is 3, prompt the user for the radius of the sphere and calculate its surface
area and volume.
 If the choice is 4, exit the program.
 If the choice is invalid, display an error message.

 Repeat:

 Continue the process until the user chooses to exit.

OUTPUT:
Example 1:
Input:
Choice: 1
Side length: 3
Output:
Total surface area of the cube: 54.0
Volume of the cube: 27.0
Example 2:
Input:
Choice: 2
Length: 2
Width: 3
Height: 4
Output:
Total surface area of the cuboid: 52.0
Volume of the cuboid: 24.0
Example 3:
Input:
Choice: 3
Radius: 5Output:
Total surface area of the sphere: 314.1592653589793
Volume of the sphere: 523.5987755982989

You might also like