-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPy_Exercise-6.py
More file actions
37 lines (28 loc) · 961 Bytes
/
Py_Exercise-6.py
File metadata and controls
37 lines (28 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -------------------------------------------------------------------------
# Author: Quang Tran
# Date: May 9th, 2019
# -------------------------------------------------------------------------
"""
Question:
Write a program that calculates and prints the value according to the given formula:
Q = Square root of [(2 * C * D)/H]
Following are the fixed values of C and H:
C is 50. H is 30.
D is the variable whose values should be input to your program in a comma-separated sequence.
Example
Let us assume the following comma separated input sequence is given to the program:
100,150,180
The output of the program should be:
18,22,24
"""
import math
def Q():
C = 50
H = 30
listOfResults = []
userInput = input("Please enter some numbers, separated by commas: ").split(",")
for D in userInput:
result = math.sqrt((2 * C * int(D)) / H)
listOfResults.append(str(int(result)))
print(",".join(listOfResults))
Q()