Python自学记录 - 005

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

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

课程:
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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值