A.I Practical 9th PDF
A.I Practical 9th PDF
CHANDAMETA
SUBMITTED BY:
CLASS: 9th B
ROLL NO: 29
ACKNOWLEDGEMENT
I wish to express my deep sense of gratitude and indebtedness to
our learned teacher VISHAL CHOURASIA
, TGT COMPUTER, SANT CHAVAR NATIONAL ACADEMY
for his invaluable help, advice and guidance in the preparation of
this project.
MOHD AZMAL
CERTIFICATE
SignatureSignature
Date:
No Practical Date Signature
i h bi
print the bigger one. 25/01/2025
9
Write a program to display one of the alternate
10 message. 25/01/2025
2. Interpreted Language: Python code is executed line by line, making debugging easier.
5. Extensive Libraries: Python comes with a vast collection of standard libraries, such as
NumPy, pandas, and matplotlib, which make it powerful for various applications.
7. High-Level Language: Python allows you to focus on problem-solving rather than low-level
system details.
10. Automation-Friendly: It is widely used for scripting and automating repetitive tasks.
Q2. Define variables and data types in Python. How do you assing a
variables?
A variable is a named location in memory used to store data that can be modified during
program execution. Variables are like containers that hold information.
Data types define the kind of value a variable holds. Python is dynamically typed, meaning
you don’t need to specify the type of variable when declaring it; Python infers the type based
on the value assigned. Common data types in Python include:
1. Numeric Types:
2. Sequence Types:
str: Strings (e.g., "hello").
3. Mapping Type:
4. Set Types:
set: Unordered and mutable collection of unique items (e.g., {1, 2, 3}).
5. Boolean Type:
6. None Type:
NoneType: Represents a null value (None).
In Python, you can assign a value to a variable using the assignment operator (=). The syntax
is:
variable_name = value
Example:
y = 3.14 # y is a float
name = "Jatin" # name is a string
Q3. Write a program to input two numbers and display their sum.
num1 = 1
num2 = 2
Output:
# Initializing values
a=5
b = 10
print(f"a = {a}")
print(f"b = {b}")
a=b
b = temp
print("\nAfter swapping:")
print(f"a = {a}")
print(f"b = {b}")
Output:
Before swapping:
a=5
b = 10
After swapping:
a = 10
b=5
volume=3.15*r*r*h
print(“volume of the cylinder is -”,volume,)
OUTPUT:
enter the radius of the cylinder – 7
enter the height of the cylinder – 11
Example Output 1:
Example Output 2:
Q7. Find the area of a rectangle whose length and breadth are 25cm and
20 cm respectively.
length = 25 # in cm
breadth = 20 # in cm
ANSWER: Here’s a Python program to calculate the area of a circle by taking the radius as
input:
Example Output 1:
Example Output 2:
ANSWER: Here's a Python program to compare two numbers and print the bigger one:
else:
print("Both numbers are equal.")
How it works:
2. It compares the two numbers using if, elif, and else conditions.
Example Output:
Case 1:
ANSWER: Here is a simple Python program that displays one of two alternative messages
based on a condition:
if choice == '1':
print("You selected the first option: Have a great day!")
elif choice == '2':
How it works:
Example Outputs:
Case 1:
Case 2:
Case 3:
if (number % 2 == 0) :
else:
print(“The number", number, "is ODD”)
Example Outputs:
Case 1:
Enter a number: 8
8 is an even number.
Case 2:
Enter a number: 15
15 is an odd number.
Q12. Write a program to find given number is positive or negative.
ANSWER: Here's a Python program that checks whether a given number is positive or
negative:
Example Outputs:
Case 1:
Enter a number: 12
12.0 is a positive number.
Case 2:
Enter a number: -5
-5.0 is a negative number.
Case 3:
Enter a number: 0
The number is zero.
else :
print(“The biggest number is : ” , c)
OUTPUT :
Enter the first number : 34
Enter the second number : 54
Example Output 1:
Enter a number: 5
The number is positive.
Enter a number: 0
The number is zero.
Enter a number: -3
The number is negative.