Question

python
Write a progran that reads values from the user until a blank line is entered. Display the total of al1 the values entered by

0 0
Add a comment Improve this question Transcribed image text
Answer #1

"""

    Python program to take input while blank line

    and prints recursive total

"""

# This function takes input recurrsively until it finds blank line and gives total of all numbers

def recursiveUntilBlank():

    inp = raw_input()   # Get the input

    if inp == "":       # If it is a blank line...

        return 0.0

    else:               # recurssive call and add value in previous result

        return float(inp) + recursiveUntilBlank()

# declare main function

def main():

    print(recursiveUntilBlank())    # call and print return value of function

# it calls main function  

if __name__== "__main__":

    main()

blankrec.py - Chegg - Visual Studio Code En * *) 9:09 AM 11 D ... blankrec.py X blankrec.py a AWN Python program to take inpuEn * O *) 9:09 AM viiju@viiju-VPCCW13EGU: -/Documents/Chegg viiju@viiju-VPCCW13EGU:-/Documents/Chegg$ python blankrec.py 0.0

Add a comment
Know the answer?
Add Answer to:
python Write a progran that reads values from the user until a blank line is entered....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT