Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
7 views2 pages

Python Programs Term1 - Gr9-2

Uploaded by

radhika fomra
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)
7 views2 pages

Python Programs Term1 - Gr9-2

Uploaded by

radhika fomra
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/ 2

1. To find the sum of two numbers.

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


b = int(input("Enter second number: "))
sum = a+b
print(“The sum of two numbers is =”, sum)

2. To convert length given in kilometers into meters.


km = float(input("Enter distance in kilometer: "))
m = km * 1000
print(”Length in meters :”, m)

3. To calculate Simple Interest if the principle_amount = 2000 rate_of_interest = 4.5


time = 10.
principal = float(input("Enter the principal amount: "))
rate = float(input("Enter the interest rate: "))
time = float(input("Enter the time period in years: "))
# Calculate simple interest
interest = (principal * rate * time) / 100
# Print the calculated simple interest
print("Simple Interest:", interest)

4. To calculate Area and Perimeter of a rectangle.

# Area & Perimeter of Rectangle


# Reading length from user
length = float(input("Enter length of the rectangle: "))
# Reading breadth from user
breadth = float(input("Enter breadth of the rectangle: "))
# Calculating area
area = length * breadth
# Calculating perimeter
perimeter = 2 * (length + breadth)
# Displaying results
print("Area of rectangle = ", area)
print("Perimeter of rectangle = ", perimeter)

5. To calculating average marks of 3 subjects.


m1 = int(input("Enter the marks of first subject: "))
m2 = int(input("Enter the marks of second subject: "))
m3 = int(input("Enter the marks of third subject: "))
total = m1+m2+m3
avg = total/3
print("Total marks: ",total)
print("Average marks: ",avg)

6. Write a Python program to swap two variables.


P = int( input("Please enter value for P: "))
Q = int( input("Please enter value for Q: "))
# To swap the value of two variables
# we will use third variable which is a temporary variable
temp = P
P=Q
Q = temp
print ("The Value of P after swapping: ", P)
print ("The Value of Q after swapping: ", Q)

You might also like