Case12. The circle elements are numbered as follows: 1 - radius R, 2 - diameter \(D = 2 \cdot R\), 3 - length \(L = 2 \cdot \pi \cdot R\), 4 - area of the circle \(S = \pi \cdot R^2\). The number of one of these elements and its value are given. Output the values of the remaining elements of a given circle (in the same order). For the value of \(\pi\) use 3.14.

Solution in Python 3:

import random
import math

r = {1 : "radius R", 2 : "diameter D", 3 : "length L", 4 : "circle area S"}
c = []

i = random.randrange(1,5)
#i = 4
print("i : ", i)
N = random.randrange(1,100)
print(r[i],":",N)
if i == 1:
R = N
c.append(R)
c.append(2 * R)
c.append(2 * math.pi * R)
c.append(math.pi * R**2)
elif i == 2:
D = N
R = D / 2
c.append(R)
c.append(D)
c.append(math.pi * D)
c.append(math.pi * R**2)
elif i == 3:
L = N
R = L / 2 / math.pi
c.append(R)
c.append(2 * R)
c.append(L)
c.append(math.pi * R**2)
elif i == 4:
S = N
R = math.sqrt(S / math.pi)
c.append(R)
c.append(2 * R)
c.append(2 * math.pi * R)
c.append(S)

print()
print("Elements of the circle:")
for i in range(0,4):
print(r[i+1],":",c[i])