"""
1、 现有面包、热狗、番茄酱、芥末酱以及洋葱,数字显 示有多少种订购组合,
其中面包必订,0 不订,1 订,比如 10000,表示只订购面包
"""
count = 0
for b in '':
for h in '':
for f in '':
for t in '':
print(b+h+f+t)
count += 1 print("一共有%s种组合" %count) """
2、输入 5 个名字,排序后输出
"""
name_list = ['Lucy','Tom','Arm','HOOT','Aood']
result = sorted(name_list)
print(result) """
3、实现一个简单的单词本
- 功能:
- 可以添加单词和词义,当所添加的单词已存在,让用户知道;
- 可以查找单词,当查找的单词不存在时,让用户知道;
- 可以删除单词,当删除的单词不存在时,让用户知道;
- 以上功能可以无限制操作,直到用户输入 bye 退出程序。
""" info = '''
add:add the word and word mean
find:find the word
del:delete the word
bye:quit the program
'''
print(info)
word_dict = {}
while 1:
commant = input("请输入指令:")
if commant == 'bye':
break
if commant == 'add':
word = input("请输入需要添加的单词:")
word_mean = input("请输入单词的意思:")
if word not in word_dict:
word_dict[word] = word_mean
else:
print("the word is already exists")
elif commant == 'find':
word = input("请输入您需要查找的单词:")
if word in word_dict:
print(word_dict[word])
else:
print("the word is not exists")
elif commant == 'del':
word = input("请输入需要删除的单词:")
if word not in word_dict:
print("the word is not exists")
else:
del word_dist[word] """
4、输入一个正整数,输出其阶乘结果
"""
n = int(input("请输入一个正整数:"))
res = 1
for i in range(1,n+1):
res *= i print(res) #5、输入 3 个数字,以逗号隔开,输出其中最大的数
nums = input("请输入3个数字,以,隔开")
nums_list = nums.split(',')
nums_int_list = list(map(int,nums_list))
print(nums_int_list)
max_num = nums_iny_list[0]
for i in nums_int_list:
if i > max_num:
max_num = i print(max_num) # 6、求两个正整数 m 和 n 的最大公约数
result = []
m = 100
n = 550
for i in range(2,m+1):
if m % i == 0 and n % i == 0:
result.append(i) for j in range(2,n+1):
if m % j == 0 and n % i == 0:
result.append(j) print(result)
print(max(result))

最新文章

  1. Linux网络编程-tcp缓存设置
  2. (一)GPIO 编程实验 LED 流水灯控制
  3. node.js基础 1之 Querystring参数处理小利器
  4. DELL_LCD错误提示代码
  5. CentOS linux下安装和配置Apache+SVN(用浏览器http方式访问SVN目录)
  6. silverlight中 Storyboard(动画)的使用,实现球的上下循环移动,左右移动,及旋转功能
  7. NHibernate中多表(对象)间的查询
  8. 三通短信每月发送量导入Sqlserver随笔
  9. Volly框架的使用基础版及使用中的一些坑 Ace 网络篇(三)
  10. NFC Forum : Frequently Asked Questions (NFC 论坛:FAQ)
  11. Mac上安装brew
  12. Vim编辑器的常用快捷键.
  13. 那万恶的ssh真是麻烦
  14. Foreman 企业级配置管理解决方案
  15. Activiti工作流学习-----基于5.19.0版本(3)
  16. nodejs添加路由route步骤详解
  17. Ubuntu火狐、Chromium等浏览器安装flash插件
  18. Java Timer及TimerTarsk(摘自网络)
  19. navicat为mysql建立索引
  20. EscapeAndUnescapeUtil【java模拟js的escape和unescape函数】

热门文章

  1. CSU 1547 Rectangle(dp、01背包)
  2. .Net-WCF-图书:《WCF编程》
  3. 备份mysql的shell
  4. mysql_DML_select_聚合join
  5. applicationContext.xml无错有红叉,Error occured processing XML 'Provider org.apache.xerces.parsers.解决方案
  6. js面向对象程序设计之属性和对象
  7. tp 框架目录结构
  8. Songwriter CF1252-E(贪心)
  9. VulnStack靶场实战(未完成)
  10. [BZOJ 3991][SDOI2015]寻宝游戏(dfs序)