Is this code correct for conversion of Celsius to fahrenheit.not working..plz help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 12

Is this code correct for conversion of Celsius to fahrenheit.not working..plz help

celsius = int(input()) def conv(): Celsius = (Fahrenheit - 32) * 5.0/9.0 celsius = conv(fahrenheit) print()

17th Dec 2020, 1:58 AM
คгשเภ๔ кย๓คг
คгשเภ๔ кย๓คг - avatar
30 Answers
+ 9
Arvind Kumar So it is Celsius to Farenheit??? Sorry bro, my bad not reading properly. celsius = float(input()) def conv(cels): fahren = (cels * 9/5) + 32 return fahren fahrenheit = conv(celsius) print(fahrenheit)
17th Dec 2020, 2:50 AM
noteve
noteve - avatar
+ 5
《 Nicko12 》 nice code by the Arvind Kumar it was a nice question
18th Dec 2020, 7:33 PM
Sneha Singh
Sneha Singh - avatar
+ 4
EDIT: (lol I focused on the code, not on the formula) celsius = float(input()) def conv(cels): fahren = (cels * 9/5) + 32 return fahren fahrenheit = conv(celsius) print(fahrenheit) - - - - - - - - - - - - - - - - - - - - - - #First, the input is to convert Celsius to Fahrenheit, so the formula must be Celsius to Fahrenheit. #Second, you should have a Paramater(cels) in the function if you want to pass an Argument(celsius) if you want to modify a certain argument. #Third, you must have a "return" keyword to return the converted value if you are assigning it to a variable. #Last, you must print the variable "fahrenheit" which has the returned or converted value to print or output the result. I hope this helps, Good Luck and Happy Coding!
17th Dec 2020, 2:02 AM
noteve
noteve - avatar
+ 4
Arvind Kumar Try this: fahrenheit = float(input()) #I forgot that it needs decimals.
17th Dec 2020, 2:38 AM
noteve
noteve - avatar
+ 4
《 Nicko12 》 Thanks for the help brother
17th Dec 2020, 2:54 AM
คгשเภ๔ кย๓คг
คгשเภ๔ кย๓คг - avatar
+ 4
Try in this manner celsius = int(input()) def conv(c): #your code goes here return(9/5 * celsius + 32) fahrenheit = conv(celsius) print(fahrenheit)
18th Dec 2020, 1:48 AM
Aysha
Aysha - avatar
+ 3
《 Nicko12 》 sorry bro your code is not working
17th Dec 2020, 2:26 AM
คгשเภ๔ кย๓คг
คгשเภ๔ кย๓คг - avatar
+ 3
《 Nicko12 》 actually it is a project question in Python and I am not able to solve it , it is not running
17th Dec 2020, 2:35 AM
คгשเภ๔ кย๓คг
คгשเภ๔ кย๓คг - avatar
+ 3
My code is running: 🥳🥳🥳 celsius = int(input) def conv(c): fahrenheit = (c * (9/5) + 32) return fahrenheit fahrenheit = conv(celsius) print (fahrenheit)
18th Dec 2020, 1:33 PM
K1auDIa KaDaM0UR0
K1auDIa KaDaM0UR0 - avatar
+ 2
fahrenheit = float(input()) def conv(fahren): cels = (fahren - 32) * 5.0/9.0 return cels celsius = conv(fahrenheit) print(celsius) #This is also not working
17th Dec 2020, 2:43 AM
คгשเภ๔ кย๓คг
คгשเภ๔ кย๓คг - avatar
+ 2
1st case input =36 Output=96.8 2nd case input=0 Output=32.0
17th Dec 2020, 2:49 AM
คгשเภ๔ кย๓คг
คгשเภ๔ кย๓คг - avatar
+ 2
Actually, the formula is provided on the question page. You just have to copy and paste into the function. https://code.sololearn.com/cmb1VX4r61pq/?ref=app
18th Dec 2020, 5:49 PM
Lam Wei Li
Lam Wei Li - avatar
+ 2
celsius = int(input()) def conv(c): #your code goes here a=((9/5) *c + 32) return a fahrenheit = conv(celsius) print(fahrenheit)
18th Dec 2020, 7:36 PM
harsh lakhara
harsh lakhara - avatar
+ 2
Sneha Singh thank u
18th Dec 2020, 7:45 PM
คгשเภ๔ кย๓คг
คгשเภ๔ кย๓คг - avatar
+ 2
Gene Awuni If u wanna know the « Celsius / Fahrenheit » code coach solution... see 6 msg. above urs !!
19th Dec 2020, 8:32 AM
K1auDIa KaDaM0UR0
K1auDIa KaDaM0UR0 - avatar
+ 2
harsh lakhara see 4 msg above u !!
19th Dec 2020, 8:38 AM
K1auDIa KaDaM0UR0
K1auDIa KaDaM0UR0 - avatar
+ 1
Arvind Kumar Its working just fine with me, Is that a challenge that needs test cases?
17th Dec 2020, 2:33 AM
noteve
noteve - avatar
+ 1
Sorry, I cant see the test cases so what are the Input and Output of the first two test case, knowing this would be a big help.
17th Dec 2020, 2:36 AM
noteve
noteve - avatar
+ 1
Okay, So, what are the test cases?
17th Dec 2020, 2:46 AM
noteve
noteve - avatar
+ 1
The problem is in your def function You should put: fahrenheit = Instead of Celsius because your are requested to get celsius degree and need convert it to fahrenheit >>>> the variable So your solution should be: celsius = int(input()) def conv(): fahrenheit = (celsius * 9 / 5) + 32 return fahrenheit fahrenheit = conv(celsius) print(fahrenheit)
18th Dec 2020, 9:49 AM
Husain Al Abbood
Husain Al Abbood - avatar