Exam Q1 Practice – SAM3

A program must calculate the circumference of a circle. The user enters the radius of the circle.
A radius of zero or less is invalid.

The formula to calculate the circumference of a circle is:
circumference = 2πr

π is the constant Pi
r is the radius.

Amend the code to add or complete lines to:
import the math library
create two variables
take input from the user
check for an invalid input of zero or less
display a message to tell the user the input is invalid
calculate the circumference
round the circumference to three decimal places using the round() function.

Do not add any additional functionality.

Scroll to Top