I am having trouble putting writing this script correctly. It is a flow chart th
ID: 3764316 • Letter: I
Question
I am having trouble putting writing this script correctly. It is a flow chart that i am following, i wish i could upload the image to be more specific. So i wrote it down.
sumy.py Flow Chart
Set sum = 0
Input y
y = int(y)
while y>= 0 true sum += y y- =1
print sum
stop
sumy.py
This script will ask the user to input a number.
The number is converted to an int named y.
A variable named sumV is set to 0.
Awhile y > 0 loop adds y to sumV, and then
decrements y by 1 (until y is no longer greater than 0.)
Then sumV is printed out.
This is what I have so far
sum = 0
y = input("Enter a number")
while y>= 0:
if true sum + = y, y-=1
else :
print(sum)
Explanation / Answer
#Here is your code
sum = 0
y = input("Enter y: ")
y = int(y)
while y>=0:
sum += y
y -= 1
print sum
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.