Python program that calculates and prints value according to formula

0 votes

 I am working on the following problem:

Writing a program that calculates and prints a value according to the formula:
Q=formula
Input variable has values that are input to program in comma-separated sequence.  The output should be formula calculated from input in comma-separated sequence.

This is the code I have so far:

import math
D=(input("Enter numbers separated by commas:" ))
D=D.split(',')
While i > 1
for each in set(list(D)):   
    C=50
    H=30
    #D=D.split(',')
    Q=math.sqrt((2*C*each)/H)
    print(Q,sep=',')

But the output is not right. Please help

Jan 8 in Python by slayer
• 29,050 points
43 views

1 answer to this question.

0 votes

Try this:

import math

c = 50

h = 30


value = []

print("Input Values")

items = [x for x in input().split(',')]

for d in items:

    value.append(str(int(round(math.sqrt(2*c*float(d)/h)))))


print("The followings output are")

print(','.join(value))
answered Jan 8 by Omkar
• 67,480 points

Related Questions In Python

0 votes
1 answer

How to sort Counter by value using python?

Use the Counter.most_common() method, it'll sort the items for you: >>> ...READ MORE

answered May 22, 2018 in Python by charlie_brown
• 7,720 points
1,694 views
+1 vote
3 answers

How to run the Python program forever?

you can also do the old fashioned ...READ MORE

answered Jun 10 in Python by brianno
567 views
0 votes
1 answer

Python using basicConfig method to log to console and file

I can't reproduce it on Python 3.3. ...READ MORE

answered Aug 14, 2018 in Python by ariaholic
• 7,340 points
41 views
0 votes
1 answer

Python using basicConfig method to log to console and file

Try this working fine(tested in python 2.7) ...READ MORE

answered Aug 27, 2018 in Python by Priyaj
• 56,520 points
838 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 232 views
+4 votes
6 answers
0 votes
2 answers

Python program to print occurrence of character in string

Try the below code inputString = input("Enter a ...READ MORE

answered Feb 26 in Python by Anubhav
• 160 points
565 views
0 votes
1 answer