Python program that calculates and prints value according to formula

–1 vote

 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, 2019 in Python by slayer
• 29,350 points
4,660 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, 2019 by Omkar
• 69,210 points

Related Questions In Python

+1 vote
1 answer
0 votes
1 answer

How to find the value of a row in a csv file in python and print column and row of that value ?

Hello @Khanhh , Use panda to find the value of ...READ MORE

answered Oct 15, 2020 in Python by Niroj
• 82,880 points
6,241 views
0 votes
1 answer
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,067 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
3,488 views
0 votes
3 answers

Python program to print occurrence of character in string

Try below code string = input("Enter a string: ...READ MORE

answered May 28, 2020 in Python by Anubhav
• 300 points
29,796 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP