0% found this document useful (0 votes)
5 views1 page

Python Code for Area and Temperature Conversion

The document describes two Python programs: one for calculating the area of a rectangle by multiplying its length and width, and another for converting Celsius to Kelvin by adding 273.15 to the Celsius input. Both programs prompt the user for input and display the results on the screen. These programs provide quick and easy calculations for users.

Uploaded by

naithetoan2005
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 views1 page

Python Code for Area and Temperature Conversion

The document describes two Python programs: one for calculating the area of a rectangle by multiplying its length and width, and another for converting Celsius to Kelvin by adding 273.15 to the Celsius input. Both programs prompt the user for input and display the results on the screen. These programs provide quick and easy calculations for users.

Uploaded by

naithetoan2005
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

1. The python code above is used to calculate area of a rectangle.

First of
all, the program asks the user to enter a real number for the length of
rectangle. Next, the function will require an input width of rectangle with a
real number type. After inputting the rectangle’s length and width, the
function shows the result on the terminal. Then, the area of rectangle is
calculated by multiply the length of rectangle by the width of rectangle.
Finally, the result will be displayed on the screen. Thanks to this program,
users can quickly know the area of rectangle.

2. The Python code above helps us to convert Celsius degrees to Kelvin.


Firstly, the program asks the user to input a real number for the Celsius
degree from the keyboard. Secondly, the program defines a function
named celsius_to_kelvin. This function is used to calculate Kelvin
temperature by adding the Celcius degree to 273.15. Then, the program
calls celsius_to_kelvin function to get Kelvin temperature with the input
variable being the Celsius degree value mentioned above. Finally, the
result will be displayed on the screen.

You might also like