当前位置: 首页 > news >正文

python高级练习题库实验1(B)部分

文章目录

  • 题目1
    • 代码
    • 实验结果
  • 题目2
    • 代码
    • 实验结果
  • 题目3
    • 代码
    • 实验结果
  • 题目4
    • 代码
    • 实验结果
  • 题目5
    • 代码
    • 实验结果
  • 题目总结


题目1

打包糖果小游戏,用户输入糖果品牌与个数,还有一个盒子里面可以装多少个糖果,输出一些打印信息,如下图所示:
在这里插入图片描述

代码

print("Packaging lollies into boxes")# ask user for lollies details
brand = input("Enter the lollies brand: ")user_input = input("Enter number of lollies: ")
count = int(user_input)user_input = input("How many lollies in 1 box? ")
per_box = int(user_input)# calculate box needed
box_count = count // per_box# calculate left over lollies
left_over = count - box_count * per_box# display result
print()
print("{0} lollies packaging calculation".format(brand))
print("Number of lollies: {0}".format(count))
print("Number of lollies per box: {0}".format(per_box))
print("Number of boxes needed
http://www.lryc.cn/news/254125.html

相关文章:

  • Qt Rsa 加解密方法使用(pkcs1, pkcs8, 以及文件存储和内存存储密钥)
  • 区分物理端口与软件端口概念:以交换机端口和Linux系统中的端口为例
  • 力扣226:翻转二叉树
  • 亚马逊鲲鹏系统智能自动注册与AI角色养号,探索数字化新境界
  • AOP操作日志记录
  • Linux C语言 42-进程间通信IPC之网络通信(套接字)
  • 微服务知识大杂烩
  • 记录一次vscode markdown的图片路径相关插件学习配置过程
  • 设计原则 | 依赖转置原则
  • 前端开发实用技巧与经验分享
  • 推荐一款Excel快速加载SQL的插件,方便又好用
  • Docker快速入门(docker加速,镜像,容器,数据卷常见命令操作整理)
  • http和https的区别有哪些
  • 使用Keil-MDK生成*.bin格式可执行文件
  • 基于springboot+vue篮球联盟管理系统源码
  • 分页助手入门以及小bug,报sql语法错误
  • Java中的并发编程:深入理解CountDownLatch
  • Windows 安装 flash-attention 和 bitsandbytes
  • AHB 与 DMA
  • React使用echarts并且修改echarts图大小
  • 【Q6-30min】
  • C++之类和对象(下)
  • 微服务开发:断路器详解
  • Leetcode—383.赎金信【简单】
  • 爬虫-xpath篇
  • Oracle初始化参数文件pfile和spfile
  • zookeeper 客户端常用命令简单记录(实操课程系列--watcher功能测试)(发布订阅功能测试)
  • Scrapy爬虫数据存储为JSON文件的解决方案
  • 计算机设计大赛 选题推荐
  • 基于springboot,vue高校图书馆管理系统