Q:

Write a program in Python to calculate the Fahrenheit of the following Celsius list by using Lambda function

0

Write a program in Python to calculate the Fahrenheit of the following Celsius list by using Lambda function

Suppose the Celsius lists are -

Celsius = [26.2, 33.2, 29.3, 32.4]

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Solution

Such a type of program plays an important role in the most scientific applications, as it is the most widely used temperature scale throughout the world. The Fahrenheit scale is mostly used in the United States.

In the Celsius scale, the boiling point of water is 100°C, and the freezing point is at 0°C, while in the Fahrenheit scale the boiling point of water is measured at 212°F and freezing point at 32°F.

celsius * 1.8 = fahrenheit - 32

Lambda is an anonymous function that contains any number of arguments, but only one expression. This function is defined without a name.

Syntax of Python lambda()
lambda arguments: expression

Here, the arguments can be of any numbers, but the expression should be only one.

This is the following solution to calculate the Fahrenheit of the following Celsius list by using Lambda function.

Celsius = [26.2, 33.2, 29.3, 32.4]
Fahrenheit = map(lambda x: (float(9)/5)*x + 32, Celsius)
print Fahrenheit
Output of the above code

[79.16, 91.76 , 84.4700000000001 , 90.3]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Python Exercises, Practice Questions and Solutions

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a program in Python to filter the given list... >>
<< Write a program in Python to calculate the value o...