0% found this document useful (0 votes)
8 views3 pages

Assignment 2

Uploaded by

645-K SRI RAMYA
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)
8 views3 pages

Assignment 2

Uploaded by

645-K SRI RAMYA
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/ 3

ASSIGNMENT-2

April 20, 2024

[1]: # ASSIGNMENT-2

[3]: # write a program on fahrenheit to celcius converter


def fahrenheit_to_celsius(fahrenheit):
"
Converts Fahrenheit to Celsius.
Formula: (F - 32) * 5/9
"
celsius = (fahrenheit - 32) * 5 / 9
return celsius
fahrenheit_value = float(input("Enter temperature in Fahrenheit: "))
celsius_value = fahrenheit_to_celsius(fahrenheit_value)
print(f"{fahrenheit_value:.2f}°F is equivalent to {celsius_value:.2f}°C.")

Enter temperature in Fahrenheit: 45


45.00°F is equivalent to 7.22°C.

[5]: # write a program on grading system using if...elif...else


name=input("Enter the student name:")
m1=int(input("Enter the mark scored in subject 1:"))
m2=int(input("Enter the mark scored in subject 2:"))
m3=int(input("Enter the mark scored in subject 3:"))
m4=int(input("Enter the mark scored in subject 4:"))
m5=int(input("Enter the mark scored in subject 5:"))
tot=m1+m2+m3+m4+m5
per=(tot/500)*100
print("Total Score =",tot )
print("Percentage ="+str(per)+"%")
if per>=80:
grade="A"
elif per>=60:
grade="B"
elif per>=40:
grade="C"
else:
grade="D"
print("Grade =",grade )

1
Enter the student name: RAMYA
Enter the mark scored in subject 1: 95
Enter the mark scored in subject 2: 85
Enter the mark scored in subject 3: 89
Enter the mark scored in subject 4: 90
Enter the mark scored in subject 5: 95
Total Score = 454
Percentage =90.8%
Grade = A

[6]: # write a program on arranging 3 numbers in ascending order


num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
num3 = int(input("Enter the third number: "))

# Sort the numbers in ascending order


if num1 <= num2 and num1 <= num3:
smallest = num1
if num2 <= num3:
middle = num2
largest = num3
else:
middle = num3
largest = num2
elif num2 <= num1 and num2 <= num3:
smallest = num2
if num1 <= num3:
middle = num1
largest = num3
else:
middle = num3
largest = num1
else:
smallest = num3
if num1 <= num2:
middle = num1
largest = num2
else:
middle = num2
largest = num1

# Print the sorted numbers in ascending order


print("Sorted numbers in ascending order:", smallest, middle, largest)

Enter the first number: 45


Enter the second number: 11
Enter the third number: 55

2
Sorted numbers in ascending order: 11 45 55

[ ]:

You might also like