0% found this document useful (0 votes)
28 views22 pages

Certificate

Ty y6yyyyyy

Uploaded by

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

Certificate

Ty y6yyyyyy

Uploaded by

saritassharma022
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

CERTIFICATE

This is to certify that _________________________ of


class IX Section____ , Bright Day School, Harni,
Vadodara has successfully completed his/her Artificial
Intelligence subject practical file as per the guidelines
issued by CBSE.

_______________

Internal Examiner
1. Take three number as input and display their sum and product on
screen.
2. Take two numbers as input. Convert these numbers to positive numbers
if they are negative numbers, convert them into negative numbers if
they are positive numbers.
3. Write a program to find area of rectangle.
4. Write a program to convert kilometers to miles in Python.
5. Write a program to convert Kelvin measurements to Celsius
6. Write a program to convert Celsius measurements to Fahrenheit.
7. Write a program to convert feet measurements to inches.
8. Write a program to find if someone is eligible to vote (age>18).
9. Write a program to find max of three numbers.
10. Write a program to basic calculator.
11. Write a program to swap the numbers.
12. Write a program to find sum and average of first N numbers.
13. Write a program to print a multiplication table of entered number
14. Create a Python program to print factorial of any number .
15. Print the pattern
*
**
***
16. Create a Python list with three items. Print the data types of these items.
17. Create a Python list containing the first 5 positive even numbers.
Display the list elements in the descending order.
18. Take three numbers as input from the user. Store these numbers in a
list. Display their product on the screen.
19. Take three names as input from the user. Store these names in a list.
Shift all three names to a single variable and delete the list.
20. Write a Python code to print squares of numbers 1 to 5 using list and
range function.
Q.1 Take three numbers as input and display their sum and product on the
screen

num1=int(input("Enter the 1st number"))

num2=int(input("Enter the 2nd number"))

num3=int(input("Enter the 3rd number"))

sum=num1+num2+num3

product=num1*num2*num3

print("The sum of three number is",sum)

print("The product of three number is",product)

Output:

Enter the 1st Number : 2

Enter the 2nd Number : 3

Enter the 3rd Number : 4

The sum of three number is : 9

The product of three number is: 24


Q.2 Take two numbers as input. Convert these numbers to positive numbers if
they are negative numbers, convert them into negative numbers if they are
positive numbers.

num1 = float(input("Enter the first number: "))

num2 = float(input("Enter the second number: "))

if num1 < 0:

num1 = (-1)*num1 # converting negative to positive

else:

num1 = -num1 # converting positive to negative

if num2 < 0:

num2 = (-1)*num2 # converting negative to positive

else:

num2 = -num2 # converting positive to negative

print("Converted numbers:")

print("Number 1:", num1)

print("Number 2:", num2)

Output:

Enter the first number: 5

Enter the Second number: -2

Converted Numbers

Number 1: -5

Number 2: 2
Q.3 Write a program to find area of rectangle.

# Taking input from the user for length and breadth of the rectangle

length = float(input("Enter the length of the rectangle: "))

width = float(input("Enter the width of the rectangle: "))

# Calculating the area of the rectangle

area = length * width

print("Area of the rectangle:", area)

Output:

Enter the length of the rectangle: 5

Enter the width of the rectangle: 6

Area of the rectangle: 30.0


Q.4 Write a program to convert kilometres to miles in Python.

# Taking input from the user for kilometers

kilometers = int(input("Enter distance in kilometers: "))

# Conversion factor: 1 kilometer is approximately 0.621371 miles

conversion_factor = 0.621371

# Calculating the distance in miles

miles = kilometers * conversion_factor

# Displaying the converted distance in miles

print(kilometers, "kilometers is equal to", miles,"miles")

Output:

Enter distance in kilometers: 240

240 kilometers is equal to 149.12904 miles.


Q.5 Write a program to convert Kelvin measurements to Celsius.

# Taking input from the user for temperature in Kelvin

kelvin = int(input("Enter temperature in Kelvin: "))

# Conversion formula from Kelvin to Celsius: Celsius = Kelvin - 273.15

celsius = kelvin - 273.15

# Displaying the temperature in Celsius

print(kelvin, "Kelvin is equal to", celsius,"degrees Celsius")

Output:

Enter temperature in Kelvin: 90

90 Kelvin is equal to -183.14999999999998 degrees Celsius


Q.6 Write a program to convert Celsius measurements to Fahrenheit.

# Taking input from the user for temperature in Celsius

celsius = int(input("Enter temperature in Celsius: "))

# Conversion formula from Celsius to Fahrenheit:

# Fahrenheit = (Celsius * 9/5) + 32

fahrenheit = (celsius * 9/5) + 32

# Displaying the temperature in Fahrenheit

print(celsius, "degrees Celsius is equal to",fahrenheit, "degrees Fahrenheit")

Output:

Enter temperature in Celsius: 120

120 degrees Celsius is equal to 248.0 degrees Fahrenheit


Q.7 Write a program to convert feet measurements to inches.

# Getting input for feet measurement from the user

feet = float(input("Enter measurement in feet: "))

# Converting feet to inches (1 foot = 12 inches)

inches = feet * 12

# Displaying the result

print(feet, "feet is equal to", inches, "inches.")

Output:

Enter measurement in feet: 30

30 feet is equal to 360.0 inches


Q.8 Write a program to find if someone is eligible to vote (age>=18).

# Getting input for age of a person

age = int(input("Enter your age: "))

if age >= 18:

print("You are eligible to vote.")

else:

print("You are not eligible to vote.")

Output:

Enter your age: 17

You are not eligible to vote.


Q.9 Write a program to find max of three numbers.

# Getting input of three numbers from user

a = float(input("Enter first number: "))

b = float(input("Enter second number: "))

c = float(input("Enter third number: "))

if a >= b and a >= c:

max_num = a

elif b >= a and b >= c:

max_num = b

else:

max_num = c

print("Maximum number is:", max_num)

Output:

Enter first number: 7

Enter second number: 9

Enter third number: 10

Maximum number is: 10.0


Q.10 Write a program to basic calculator.

# Getting input of two numbers from user

a = float(input("Enter first number: "))

b = float(input("Enter second number: "))

# Getting input of arithmetic operation that user wants

operation = input("Enter operation (+, -, *, /): ")

if operation == '+':

result = a + b

elif operation == '-':

result = a - b

elif operation == '*':

result = a * b

elif operation == '/':

result = a / b

else:

result = "Invalid operation"

print("Result:", result)

Output:

Enter first number: 7

Enter second number: 8

Enter operation (+, -, *, /): *

Result: 56.0
Q.11 Write a program to swap the numbers.

# Getting input of two numbers from user.

a = float(input("Enter first number: "))

b = float(input("Enter second number: "))

print("The numbers before swapping are:")

print("First Number : ",a)

print("Second Number : ",b)

# Swapping means exchanging the values between two variables

temp = a

a=b

b = temp

print("The numbers after swapping are:")

print("First Number : ",a)

print("Second Number : ",b)

Output:

Enter first number: 20

Enter second number: 40

The numbers before swapping are:

First Number : 20.0

Second Number : 40.0

The numbers after swapping are:

First Number : 40.0

Second Number : 20.0


Q.12 Write a program to find sum and average of first N numbers

# Getting input of natural number from user:

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

sum_N = N * (N + 1) // 2

average = sum_N / N

print("Sum of first", N, "numbers is:", sum_N)

print("Average of first", N, "numbers is:", average)

Output:

Enter a number: 6

Sum of first 6 numbers is: 21

Average of first 6 numbers is: 3.5


Q.13 Write a program to print a multiplication table of entered number.

#Getting input from user for multiplication table

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

print("The multiplication table of ", num ," is :")

for i in range(1, 11):

print(num, "x", i, "=", num * i)

Output:

Enter a number: 7

The multiplication table of 7 is :

7x1=7

7 x 2 = 14

7 x 3 = 21

7 x 4 = 28

7 x 5 = 35

7 x 6 = 42

7 x 7 = 49

7 x 8 = 56

7 x 9 = 63

7 x 10 = 70
Q.14 Create a Python program to print factorial of any number .

#Getting input from user for factorial

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

factorial = 1

if num < 0:

print(" Factorial does not exist for negative numbers")

elif num == 0:

print("The factorial of 0 is 1")

else:

for i in range(1,num + 1):

factorial = factorial*i

print("The factorial of",num,"is",factorial)

Output:

Enter a number: 8

The factorial of 8 is 40320


Q.15 Print the pattern

**

***

# Programme to print the given pattern

print("The given pattern is :")

for i in range(1, 4):

print("* " * i)

Output:

The given pattern is :

**

***
Q.16 Create a Python list with three items. Print the data types of these items.

lst = ['school', 2, 4.5]

for element in lst:

print (type(element))

Output:

<class 'str'>

<class 'int'>

<class 'float'>
Q.17 Create a Python list containing the first 5 positive even numbers. Display
the list elements in the descending order.

#List of First 5 Positive Even Numbers

even_numbers = [2, 4, 6, 8, 10]

print("Even numbers in descending order:", sorted(even_numbers, reverse=True))

Output:

Even numbers in descending order: [10, 8, 6, 4, 2]


Q.18 Take three numbers as input from the user. Store these numbers in a list.
Display their product on the screen.

# Taking input from the user for three numbers

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

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

num3 = int(input("Enter the third number: "))

# Store the numbers in a list

numbers = [num1, num2, num3]

# Calculate the product of the numbers

product = numbers[0] * numbers[1] * numbers[2]

# Display the product on the screen

print("The product of the numbers is:", product)

Output:

Enter the first number: 6

Enter the second number: 7

Enter the third number: 8

The product of the numbers is: 336


Q.19 Take three names as input from the user. Store these names in a list. Shift
all three names to a single variable and delete the list.

# Taking input for three names

name1 = input("Enter first name: ")

name2 = input("Enter second name: ")

name3 = input("Enter third name: ")

# Storing names in a list

names_list = [name1, name2, name3]

# Shifting all three names to a single variable

all_names = ' '.join(names_list)

# Deleting the list to free up memory

del names_list

# Printing the shifted names stored in a single variable

print("All names shifted to a single variable:", all_names)

Output:

Enter first name: Rishi

Enter second name: Kumar

Enter third name: Thakkar

All names shifted to a single variable: Rishi Kumar Thakkar


Q.20 Write a Python code to print squares of numbers 1 to 5 using list and range
function.

#Squares of Numbers 1 to 5:

squares = [x ** 2 for x in range(1, 6)]

print("Squares of numbers 1 to 5:", squares)

Output:

Squares of numbers 1 to 5: [1, 4, 9, 16, 25]

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy