Using Python 3 Solve the following problems by writing a sma
Using Python
3. Solve the following problems by writing a small program: a) Three people ate dinner at a restaurant and want to split the bill. The total is $35.27, and they want to leave a 15 percent tip. How much should each person pay? b) Calculate the area and perimeter of a rectangular room, 12.5 meters by 16.7 meters.
Solution
Answer:A
bill=35.27
tips = bill*0.15
print \"Total bill is : %f\"%(bill+tips)
Output:
Total bill is : 40.560500
Answer:B
def area(length, width):
return length*width
def perimeter(length,width):
return 2*(length+width)
length = 12.5
width = 16.7
print \"Area of a rectangular room is: %f\"%area(length,width)
print \"Perimeter of a rectangular room is: %f\"%perimeter(length,width)
Output:
Area is: 208.750000
Perimeter is: 58.400000
