0% found this document useful (0 votes)
4 views

Simple 10 Python Programs

The document contains ten simple Python programs that cover basic programming concepts such as input/output, arithmetic operations, and data type conversions. Each program includes instructions for user input and provides specific outputs, including calculating sums, areas, BMI, and conversions between units. The programs are designed for beginners to practice and understand fundamental Python programming skills.

Uploaded by

Sunil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Simple 10 Python Programs

The document contains ten simple Python programs that cover basic programming concepts such as input/output, arithmetic operations, and data type conversions. Each program includes instructions for user input and provides specific outputs, including calculating sums, areas, BMI, and conversions between units. The programs are designed for beginners to practice and understand fundamental Python programming skills.

Uploaded by

Sunil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Simple 10 python programs

Please go thru it, understand it and do it in your system,laptop or mobile


app
Write a program to input a welcome message
and print it
message = input(“Enter welcome message:”)
print(“Hello,”,message)

Enter welcome message as “Python welcomes you to its beautiful


world” or anything you like.
2. Program to obtain three numbers and print
their sum
# 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)
3.Program to obtain length and breadth of a
rectangle and calculate its area
# to input length and bredth 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(“Aread=“,area)
4.Program to calculate BMI (Body Mass Index) of a person. Body Mass Index is a
simple calculation using a peson’s height and weight.
The formula is BMI = kg/m2 where kg is a peson’s weight in kilograms and m2 is
their height in meters squared

# to calculate BMI = kg/m square


weight_in_kg = float(input(“Enter weight in kg:”))
height_in_meter = float(input(“Enter height in meters:”))
bmi=weight_in_kg/(height_in_meter * height_in_meter)
print(“BMI is:”,bmi)
5.Write a program to input a number and
print its cube
num=int(input(“Enter a number:”))
cube=num*num*num
print(“Number is”, num)
print(“Its cube is,”cube)
6 Write a program to input a value in kilometers
and convert it into miles (1 km = 0.621371 miles)
km = int(input(“Enter kilometers:”))
miles = km * 0.621371
print(“kilometres:”, km)
print(“Miles:”,miles)
7 write a program to input a value in tonnes and
convert it into quintals and kilograms.
(1 tonne – 10 quintals 1 tonne= 1000 kgs, 1 quintal
= 100 kgs)

tonnes = float(input(“Enter tonnes:”))


quintals = tonnes * 10
kgs = quintals * 100
print(“Quintals:”, quintals)
print(“kilograms:”,kgs)
8. Write a program to enter a small poem or
poem verse and print it.
poem = input(“Enter a small poem:”)
print(“The poem you entered”)
print(poem)
9. Write a program to input two numbers and
swap them.
n1=int(input(“Enter number 1: “))
n2=int(input(“Enter number 2:”))
print(“Original numbers:”,n1,n2)
n1,n2 = n2,n1
print(“Afte swaping”,n1,n2)
10 Write a program to input three numbers and
swap them as this: Ist number becomes the 2nd
number, 2nd number becomes the 3rd number and
3rd number becomes the first number
x=int(input(“Enter number 1 :”))
y=int(input(“Enter number 2:”))
z=int(input(“Enter number 3:”))
Print(“Orginal numbes:”,x,y,z)
x,y,z = y,z,x
print(“After swapping:”,x,y,z)

You might also like