Hello people.

I learning phyton and have a problem.

def Cel2Fah(temp): 
	Fahren = str((9.0/5.0)*temp+32);
	return Fahren;

I was asked to write a function which converts celsius to fahrenheit(http://www.pyschools.com/quiz/view_question/s2-q5).
It says: "Return a string of 2 decimal places", but i dont know how to.

Recommended Answers

All 3 Replies

Use formatting string with % or newer .format string method.

Use formatting string with % or newer .format string method.

Ok, thanks i will google them.

EDIT: THANKS VERY MUCH.
IT WORKED

As pyTony said, .format works pretty well.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.