0% found this document useful (0 votes)
5 views6 pages

Dash Ps 12

The document contains various Python programs demonstrating basic input/output operations, arithmetic calculations, and variable manipulation. Each program includes user prompts for input and displays corresponding outputs, such as calculating sums, areas, BMI, and converting units. Additionally, it showcases swapping values and printing user-provided text, including a poem.

Uploaded by

dneb2372008
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)
5 views6 pages

Dash Ps 12

The document contains various Python programs demonstrating basic input/output operations, arithmetic calculations, and variable manipulation. Each program includes user prompts for input and displays corresponding outputs, such as calculating sums, areas, BMI, and converting units. Additionally, it showcases swapping values and printing user-provided text, including a poem.

Uploaded by

dneb2372008
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/ 6

Program

Message = input(“Enter welcome message :”)


Print”Hello,”message)

OUTPUT
Enter a welcome message :Pythons welcomes youto it beautiful world .

Hello, Python welcomes you a beautiful world

Program 1
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)

Enter Number 1 : 5
Output
Enter Number 2 : 4

Enter Number 3 : 3

Three Numbers are : 5 4 3

Sum is : 12
Program 2
length=float(input("Enter the length of rectangle : "))

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

area=length*breadth

print("Rectangle specifications ")

print("Length : ",length," Breadth : ",breadth," Area : ",area)

Output

Enter the length of rectangle : 6

Enter the breadth of rectangle : 5

Rectangle specifications

Length : 6.0 Breadth : 5.0 Area : 30.0

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 meters: "))

bmi-weight_in_kg/(height_in meter height_in_meter)

print("BMI is: ", bmi)


Output
Enter weight in kg : 66

Enter hiegth in meter :1.6

BMI is : 25.78

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

cube= num*num*num

print("Number is", num)

print("Its cube is", cube)

OUTPUT
Enter number : 7

Number is 7

Its cube is 343

PROGRAM
km=int(input("Enter kilometres: "))

miles=km0.621371

print("Kilometres:", km)

print("Miles:", miles)

OUTPUT
Enter kilometres: 20

Kilometres: 20

Miles: 12.42742

PROGRAM
tonnes float(input("Enter tonnes: "))

quintals tonnes * 10

kgs quintals* 100

print("Tonnes:", tonnes)

print("Quintals:", quintals)

print("Kilograms:", kgs)

OUTPUT
Enter tonnes: 2.5
Tonnes: 2.5

Quintles:25

Kilograms:2500

PROGRAM
num1 = input('Enter First Number: ')
num2 = input('Enter Second Number: ')
print("Value of num1 before swapping: ", num1)
print("Value of num2 before swapping: ", num2)
# swapping two numbers without using temporary variable
num1, num2 = num2, num1
print("Value of num1 after swapping: ", num1)
print("Value of num2 after swapping: ", num2)

OUTPUT
Enter First Number: 101
Enter Second Number: 99
Value of num1 before swapping: 101
Value of num2 before swapping: 99
Value of num1 after swapping: 99
Value of num2 after swapping: 101

PROGRAM
n1=int(input("Enter number 1 : "))

n2=int(input("Enter number 2 : "))

n3=int(input("Enter number 3 : "))

print("Original Number : ",n1,n2,n3)


n1,n2,n3=n2,n3,n1

print("After Swapping : ",n1,n2,n3)

OUPUT
Enter number 1 : 4

Enter number 2 : 5

Enter number 3 : 6

Original Number : 4 5 6

After Swapping : 5 6 4

PROGRAM
poem input("Enter a small poem: ")

print("The poem you entered")

print (poem)

OUPUT
Enter a small poem: "Hope" is the thing with feathers- That perches in the soul sings the tune
without the words And never stops at all -EMILY DICKINSON

The poem you entered the words the thing with feathers- That perches in the soul- And sings the
tune wit And never stops at all EMILY DICKINSON

You might also like