You are on page 1of 4

CHITTAGONG UNIVERSITY OF

ENGINEERING AND TECHNOLOGY

Department of Urban and Regional Planning


Course Name: Programming for Planners
Course ID: CSE 282

Experiment No. Experiment Title


01 Convert a temperature reading in degrees
Fahrenheit to degrees Celsius, using the formula
C = (5/9)* (F- 32).

Name: Norin Binte Khorshed Megha


Student ID: 2005028
Level: 2
Term: II
Date of Submission: 4th September, 2023
Marks:
Title:

Convert a temperature reading in degrees Fahrenheit to degrees Celsius, using the formula C
= (5/9)* (F- 32) Test the program with the following values: 68, 150, 212, 0, -22, -200 (degrees
in Fahrenheit).

Objective:

1. To learn about data type, variable and constant in Python.


2. To apply the mathematical operations for solving complex problems.
3. To understand the methods of variable declaration, type casting {conversion using str(),
int(),float()} and string formatting.

Introduction:

Python is a high-level, interpreted programming language known for its simplicity and
readability. It is used for a wide range of applications, including web development, data
analysis, machine learning, scientific computing, automation, and more. It supports all of the
math operations that one can expect. The basic ones are addition, subtraction, multiplication,
and division

If we want to convert temperature reading from Fahrenheit to Celsius, we need to use some
basic mathematical operations like subtraction (-), multiplication (*), and division (/).
Generally, the first step is variable declaration which refers to process of defining a variable
and specifying its data type. Type casting or type conversion is also used. It refers to the process
of changing the data type of a variable or an expression from one type to another. Then we use,
string formatting. It is the process of creating strings with placeholders that can be replaced
with values.

Discussion:

To convert temperature reading from Fahrenheit to Celsius, we need to input a variable (F) for
Fahrenheit reading. It is a variable and it must be an integer. Here users can put their desire
number which they want to convert. Then we need to convert the data to integer because input
function considers data as string automatically. We will type a formula for converting the

1
temperature from Fahrenheit to Celsius next. The formula is C= ((5/9)*(F-32)). So, it is
predefined by the coder. We will test the program with the following values: 68, 150, 212, 0,
-22, -200 (degrees Fahrenheit). After putting the integer value and running the code, the desire
Celsius value will come.

Source Code and Output:

For source code, we need to take F (Fahrenheit) using input function where any value can be
given. We had previously taken some values like 68, 150, 212, 0, -22, and -200 (Degrees
Fahrenheit). Now we will enter these values respectively. There an example is shown with 68-
degree Fahrenheit. Then we need to do type casting and write the formula for conversion.

The output will come with a value of Celsius. After testing one value we will test other values
respectively. For 68 degree Fahrenheit, we got 20 degree Celsius.

2
Conclusion:

Python is renowned for being easy to read and understand. Both novice and seasoned
programmers favor Python because of its adaptability, simplicity of learning, and robust
ecosystem. But a coder can face some challenges like:

 It is important to follow some basic rules of coding like using brackets, using inverted
coma (“”) in appropriate place, using numeric and string values perfectly.
 The length should not be normally more than 8 characters.
 It should not be a keyword, but keyword can be a part of variable, such as int_type
could be a variable, but int couldn't function in that way.
 Python is case sensitive thus uppercase and lowercase are significant. F and f will not
be same variable.
 White spaces should be avoided.

---------------------------------------------------------------------------------------------------------------

You might also like