COMPUTER
PROJECT FILE
By- Kushal Goel
Class- 9D
# WAP TO ENTER DIMENSIONS OF A RIGHT-ANGLE TRIANGLE AND FIND
ITS PERIMETER AND AREA
Input:
l= loat(input("Enter the 1st side of right-angled triangle:"))
b= loat(input("Enter the 2nd side of right-angled triangle:"))
h= loat(input("Enter the 3rd side of right-angled triangle:"))
print("Permimeter of triangle is ",l+b+h)
print("Area of triangle is ",0.5*b*h)
Output
# WAP TO ENTER TEMPERATURE IN KELVIN AND CONVERT IT INTO
CELSIUS AND FAHRENHEIT
Input:
k= loat(input("Enter temperature in Kelvin : "))
print("Temperature",k,"K in Celsius : ",k - 273.15,"C")
print("Temperature",k,"K in Fahrenheit : ",(k - 273.15) * 9/5 + 32,"F")
Output:
# WAP TO ENTER HEIGHT IN METRE AND FEET AND CONVERT IT INTO
CENTIMETRES
Input:
m= loat(input("Enter height in metre = "))
f= loat(input("Enter height in feet = "))
print("Height in centimeter from metre = ",m*100)
print("Height in centimeter from feet = ", f*30)
Output:
# WAP TO ENTER TWO VALUES AND PERFORM ARITHMETIC
CALCULATIONS
Input:
a = loat(input("Enter irst number : "))
b = loat(input("Enter second number : "))
print("Sum:", a + b)
print("Subtraction:", a - b)
print("Multiplication:", a * b)
print("Division:", a / b)
print("Floor division:", a // b)
print("Remainder:", a % b)
print("Exponentiation:", a ** b)
Output:
# WAP TO ENTER 2 TIME VALUES, THEN FIND THE TOTAL TIME
Input:
hr1 = int(input("Enter hours for Time 1 :" ))
hr2 = int(input ("Enter hours for Time 2 : "))
min1 = int(input("Enter minutes for Time 1 : "))
min2= int(input ("Enter minutes for Time 2 : "))
sec1= int (input ("Enter seconds for Time 1 : "))
sec2 = int(input("Enter seconds for Time 2 : "))
secs = (sec1+sec2) % 60
mins= (min1 + min2) % 60 + (sec1 + sec2) // 60
hours= (hr1+hr2) + (min1 + min2 ) // 60
print("Time 1 -->", hr1, ": ", min1,":",sec1)
print("Time 2 -->",hr2, ": ", min2,":",sec2)
print("---------------------------------------")
print("Time Sum =",hours,":", mins,":",secs )
print("---------------------------------------")
Output:
# WAP TO ENTER THE NUMBER OF DAYS AND FIND YEARS, MONTHS,
WEEKS AND DAYS THAT CAN BE DERIVED FROM THE SUPPLIED
NUMBER OF DAYS
Input:
d=int(input("Enter the number of days : "))
year=d//365
dl1=d%365
month=dl1//30
dl2=dl1%30
week=dl2//7
days=dl2%7
print("Year Months Weeks Days")
print("----------------------------------------------------")
print(year," ",month," ",week," ",days)
print("----------------------------------------------------")
Output:
#WAP TO ENTER TWO ANGLES OF A TRIANGLE BY ONE PERSON, AND
THE SECOND PERSON HAS TO ENTER THE THIRD ANGLE. SHOW THE
TRUE OR FALSE RESULT IF THE TRIANGLE IS APPLICABLE
WITH THESE ANGLES
Input:
a= loat(input("Enter the irst angle of the triangle : "))
b= loat(input("Enter the second angle of the triangle : "))
c= loat(input("Enter the third angle of the triangle : "))
if (a+b+c)==180 and a>0 and b>0 and c>0:
print("True")
else:
print("False")
Output:
KUSHAL GOEL / 26 / IX D
#WAP TO FIND DISTANCE BETWEEN TWO POINTS, WHILE COORDINATES
OF THESE TWO ARE THESE TWO POINTS ARE ENTERED BY THE USER,
DISTANCE = X(X1 - X2), Y(Y1 - Y2). DISTANCE = SQRT ((X1-X2)**2)+ ((Y1-
Y2)**2)
Input:
x1=int(input("Enter x1 coordinate for point x : "))
x2=int(input("Enter x1 coordinate for point x : "))
y1=int(input("Enter x1 coordinate for point y : "))
y2=int(input("Enter x1 coordinate for point y : "))
d= ((x1-x2)**2) + ((y1 - y2)**2)**1/2
print("Distance = ",round(d,2))
Output:
KUSHAL GOEL / 26 / IX D
# WRITE A PYTHON PROGRAM THAT ACCEPTS RADIUS OF A CIRCLE
AND PRINTS ITS AREA.
Input-
r= loat(input("Enter the radius of the circle : "))
print("Area of the circle is : ",3.14*(r**2))
Output-
# WRITE A PYTHON PROGRAM THAT ACCEPTS MARKS IN FIVE
SUBJECTS AND OUTPUTS THE AVERAGE MARKS.
Input-
a= loat(input("Enter marks of the irst subject : "))
b= loat(input("Enter marks of the second subject : "))
c= loat(input("Enter marks of the third subject : "))
d= loat(input("Enter marks of the fourth subject : "))
e= loat(input("Enter marks of the ifth subject : "))
avg=(a+b+c+d+e)/5
print("Average of the 5 subjects is : ",avg)
Output-
KUSHAL GOEL / 26 / IX D
#WRITE A PROGRAM TO FIND THE AREA OF A TRIANGLE.
Input-
h= loat(input("Enter the height of the triangle : "))
b= loat(input("Enter the base of the triangle : "))
print("Area of the triangle is : ",0.5*h*b)
Output-
#WRITE A PROGRAM TO INPUT A NUMBER AND PRINT ITS FIRST FIVE
MULTIPLES.
Input-
a= loat(input("Enter a number :"))
for i in range(1,6):
print("\nFirst 5 multiples of ",a," are :",a*i)
Output-
KUSHAL GOEL / 26 / IX D
#WRITE A PROGRAM TO READ DETAILS LIKE NAME, CLASS, AGE OF A
STUDENT AND THEN PRINT THE DETAILS, FIRSTLY IN THE SAME LINE
AND THEN IN SEPARATE LINES.
Input-
n=input("Enter the name of the student : ")
c=input("Enter the class of the student : ")
a=int(input("Enter the age of the student : "))
print("Name of the student :",n,"; Class :",c,"; Age :",a)
print("\n")
print("\nName of the student :",n)
print("Class :",c)
print("Age :",a)
Output-
KUSHAL GOEL / 26 / IX D
# WRITE A PROGRAM TO READ THREE NUMBERS IN THREE VARIABLES
AND SWAP THE FIRST TWO VARIABLES WITH THE SUMS OF FIRST AND
SECOND, SECOND AND THIRD NUMBERS, RESPECTIVELY.
Input-
a= loat(input("Enter the irst number : "))
b= loat(input("Enter the second number : "))
c= loat(input("Enter the third number : "))
a=a+b
b=b+c
print("After swapping:")
print("First number:", a)
print("Second number:", b)
print("Third number:", c)
Output-
KUSHAL GOEL / 26 / IX D
# WRITE A PROGRAM TO SWAP TWO NUMBERS WITHOUT USING A
THIRD VARIABLE.
Input-
a= loat(input("Enter the irst number : "))
b= loat(input("Enter the second number : "))
a,b=b,a
print("After swapping:")
print("First number:", a)
print("Second number:", b)
Output-
# WRITE A PROGRAM TO SWAP TWO NUMBERS WITH USING A THIRD
VARIABLE.
Input-
a= loat(input("Enter the irst number : "))
b= loat(input("Enter the second number : "))
c=a
a=b
b=c
print("After swapping:")
print("First number:", a)
print("Second number:", b)
Output-
KUSHAL GOEL / 26 / IX D
# WRITE A PROGRAM TO CHECK WHTHER A YEAR IS LEAP YEAR OR
NOT
Input-
y=int(input("Enter a year :"))
if y>-1 and y%4==0:
print(y,"is a leap year")
else:
print(y,"is not a leap year")
Output-
KUSHAL GOEL / 26 / IX D
# WRITE A PROGRAM THAT ASKS THE USER TO ENTER THEIR NAME
AND AGE PRINT A MESSAGE ADDRESSED TO THE USER THAT TELLS THE
USER THE YEAR IN WHICH THEY WILL TURN 100 YEARS OLD.
Input-
n=input("Enter your name : ")
a=int(input("Enter your age : "))
c=int(input("Enter the current year : "))
yt100=100+(c-a)
if c>=0 and a>=0:
print("You will turn 100 years old in ",yt100)
else:
print("Input in invalid")
Output-
KUSHAL GOEL / 26 / IX D
# WAP IN PYTHON TO ENTER A 3-DIGIT NUMBER THEN FIND THE
SQUARE OF THE FIRST AND LAST DIGIT OF THE NUMBER
Input-
a=int(input("Enter a 3-digit number : "))
b=a//100
c=a%10
if (a>99) and (a<1000):
print("The square of irst digit of the number is : ",b**2)
print("The square of last digit of the number is : ",c**2)
else:
print("The given number is not a 3-digit number")
Output-
KUSHAL GOEL / 26 / IX D
# WAP IN PYTHON TO ENTER A 3-DIGIT NUMBER THEN FIND THE SUM
OF THE SQUARE OF THE FIRST AND LAST DIGIT OF THE NUMBER
Input-
a=int(input("Enter a 3-digit number : "))
b=a%10
s1=b**2
c=a//100
s2=c**2
s_sum= s2 + s1
if a>99 and a<1000:
print("The sum of square of last and irst digit is : ",s_sum)
else:
print("The given number is not a 3-digit number")
Output-
KUSHAL GOEL / 26 / IX D
#WAP IN PYTHON TO ENTER 3 NUMBERS THEN SHOW THE SECOND
HIGHEST NUMBER
Input-
a= loat(input("Enter a number : "))
b= loat(input("Enter a number : "))
c= loat(input("Enter a number : "))
if a!=b!=c!=a :
if a<b<c or c<b<a:
print("Second highest number is : ",int(b))
elif b<a<c or c<a<b:
print("Second highest number is : ",int(a))
elif b<c<a or a<c<b:
print("Second highest number is : ",int(c))
else:
print("Please enter 3 different numbers")
Output-
KUSHAL GOEL / 26 / IX D