课程:
Microsoft: DEV236x
Introduction to Python: Absolute Beginner
课时:
Final Required Code
习题:
Program: adding_report() function
This program calls the adding_report() function which repeatedly takes positive integer input until the user quits and then sums the integers and prints a “report”.
The adding_report() function has 1 string parameter which indicates the type of report:
“A” used as the argument to adding_report() results in printing of all of the input integers and the total
“T” used as the argument results in printing only the total
Sample input and output:
call adding_report() with “A” as argument (print all the integers entered and the total)
Input an integer to add to the total or “Q” to quit
Enter an integer or “Q”: 3
Enter an integer or “Q”: 6
Enter an integer or “Q”: 24
Enter an integer or “Q”: 17
Enter an integer or “Q”: 61
Enter an integer or “Q”: nine
nine is invalid input
En

本文记录了一位作者在自学Python过程中遇到的一道难题,涉及编写一个名为`adding_report()`的函数,该函数根据参数打印输入的整数和/或总和。作者在理解微软课程中的示例和逻辑图时遇到困扰,但最终依靠自己的思路成功解决问题。作者强调编程时清晰的思路和逻辑的重要性,并分享了解题后的成就感。
最低0.47元/天 解锁文章
785

被折叠的 条评论
为什么被折叠?



