0% found this document useful (0 votes)
36 views12 pages

Kishan Jaiswal XI C

This document outlines 10 programming problems including programs to calculate the sum of 3 numbers, the area of a rectangle, BMI, conversion between km to miles and tonnes to quintals/kilograms, swapping values, finding the average of 3 numbers, checking if a number is even or odd, and finding the largest of 3 numbers. Sample inputs and outputs are provided for each program.

Uploaded by

kishan1331c
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)
36 views12 pages

Kishan Jaiswal XI C

This document outlines 10 programming problems including programs to calculate the sum of 3 numbers, the area of a rectangle, BMI, conversion between km to miles and tonnes to quintals/kilograms, swapping values, finding the average of 3 numbers, checking if a number is even or odd, and finding the largest of 3 numbers. Sample inputs and outputs are provided for each program.

Uploaded by

kishan1331c
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/ 12

INDEX

1.Program to obtain three numbers and print their sum.


2.Program to obtain length and breadth of a rectangle and
calculate its area.
3.Program to calculate BMI of a person.
4.Program to input a value in kilometres and convert it into
miles.
5.Program to input a value in tonnes and convert it into
quintals and kilogram.
6.Program to input two numbers and swap them.
7.Program to input three numbers and swap them as this:1st
no. becomes the 2nd no.,2nd no. becomes the 1st no.
8.Program to find average of three numbers.
9.Program that takes a number and checks whether the given
number is odd or even.
10.Program to accept three integers and print the largest of
the three.
Program |1

# to input 3 numbers and print their sum


num1 = int(input(“Enter number 1: ”))
num2 = int(input(“Enter number 2: ”))
num3 = int(input(“Enter number 3: ”))
Sum = num1 + num2 + num3
print(“Three numbers are: ”, num1, num2, num3)
print(“Sum is: ”, Sum)
Sample run:
Enter number 1 : 7
Enter number 2 : 3
Enter number 3 : 13
Three numbers are : 7 3
13
Sum is : 23
Program| 2
# to input length and breadth of a rectangle and calculate its area
length = float(input("Enter length of the rectangle: "))
breadth = float(input("Enter breadth of the rectangle: "))

area = length * breadth

print(‘”Rectangle specifications ”)
print(“Length = “, length, end = ‘’)
print(“breadth = “, breadth)
print(“Area = ”, area)

Sample Run:
Enter length of the rectangle : 8.75
Enter breadth of the rectangle : 35.0

Rectangle specifications

Length = 8.75 Breadth = 35.0


Area = 306.25
Program|3

#to calculate BMI=kg/m square


weight_in_kg=float(input(“Enter weight in kg:”))
height_in_meter=float(input(“Enter height in metres:”))
bmi=weight_in _kg/(height_in_metre*height_in_meter)
print(“BMI is:”,bmi)

Sample run:
Enter weight in kg : 66
Enter height in meters : 1.6
BMI is : 25.781249999
Program|4
km = int(input(“Enter kilometers: ”))
miles = km * 0.621371
print(“Kilometers : ”, km)
print(“Miles : “, miles)

Sample Run:
Enter kilometres : 20
Kilometres : 20
Miles : 343
Program |5

tonnes=float(input(“Enter tonnes:”))
quintals=tonnes*10
kgs=quintals*100
print(“Tonnes :”, tonnes)
print(“Quintals :”, quintals)
print(“Kilograms :”,kgs)

Sample run:
Enter tonnes : 2.5
Tonnes : 2.5
Quintals:25.0
Kilograms : 2500.0
Program| 6

n1=int(input(“Enter number 1 :”))


n2=int(input(“Enter number 2 :”))
print(“Original numbers :”, n1, n2)
n1,n2=n2,n1
print(“After swapping :”,n1,n2)

Sample run:
Enter number1 : 17
Enter number 2 : 28
Original numbers : 17 28
After swapping : 28 17
Program |7

x=int(input(“Enter number 1 :”))


y=int(input(“Enter number 2 :”))
z=int(input(“Enter number 3 :”))
print(“Original numbers : “, x,y,z)

x,y,z=y,z,x
print(“After swapping :”,x,y,z)

Sample run:
Enter number 1 : 6
Enter number 2 : 11
Enter number 3 : 9
Original numbers : 6 11 09
After swapping : 11.9 6
Program |8

x = int(input(Enter value 1 :”))


y = int(input(Enter value 2 :”))
z = int(input(Enter value 3 :”))
print(“Three numbers are :” , x, y, z)
avg = (x + y + z)/3
print(“Average of given numbers : ”, avg)

OUTPUT:
Enter value 1 : 14
Enter value 2 : 12
Enter value 3 : 13
Three numbers are : 14, 12, 13
Average of given numbers : 13.0
Program |9

num = int(input(“Enter a integer : ”))


if num % 2 == 0
print(num, “is EVEN Number. “)
else:
print(num, “is ODD Number. ”)

OUTPUT:
Enter an integer : 8
8 is EVEN Number
P r o g r a m | 10

x=y=z=0
x = float(input(“Enter first number: ”))
y = float(input(“Enter second number: ”))
z = float(input(“Enter third number: ”))

max = x
if y > max:
max = y
if z > max:
max = z
print(“Largest number is”, max)

OUTPUT:
Enter first number: 7.235
Enter second number: 6.99
Enter third number: 7.533
Largest number is : 7.533

You might also like