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,040 points
14 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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
• 65,820 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,710 points
1,025 views
0 votes
2 answers

How to run the Python program forever?

No, you can use while: pass I ...READ MORE

answered 14 hours ago in Python by Lehan
314 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,320 points
24 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,100 points
366 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
19 views
+4 votes
6 answers
+1 vote
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
96 views
0 votes
1 answer

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.