| |
| == |
| |
| != |
| |
| > |
| |
| >= |
| |
| < |
| |
| <= |
| |
| 2 < num <= 5 |
| num > 2 and num <=5 |
| |
| 表达式1 and 表达式2 |
| |
| 表达式1 or 表达式2 |
| |
| not 表达式1 |
| |
| if len(phone) > 11: |
| print('输入正确') |
| |
| |
| if len(phone) > 11: |
| print('输入错误') |
| else: |
| print('输入正确') |
| |
| |
| if len(phone) > 11: |
| print('输入错误') |
| elif phone.isdigit(): |
| print('输入错误') |
| else: |
| print('输入正确') |
| |
| |
| a=12 |
| def test(): |
| if a < 11: |
| print('输入错误') |
| return 11 |
| elif a > 22: |
| print('输入错误') |
| return 22 |
| else: |
| print('输入正确') |
| return 33 |
| b = test() |
| print(b) |
| |
| |
| a=12 |
| def test(): |
| if a < 11: |
| print('输入错误') |
| elif a > 22: |
| print('输入错误') |
| else: |
| print('输入正确') |
| return a |
| b = test() |
| print(b) |
| while 条件为true时: |
| |
| |
| i = 1 |
| while i <= 100: |
| print(i) |
| i += 1 |
| list= [123, 456] |
| for a in list: |
| print(a) |
| |
| for n in range(100): |
| print(n) |
| |
| |
| for n in range(50,101): |
| print(n) |
| |
| |
| for n in range(50,101,5): |
| print(n) |
| |
| list = ['aaa', 'bbb', 'ccc'] |
| for idx, a in enumerate(list): |
| print(f'{idx},{a}') |
| while True: |
| command = input("请输入命令:") |
| if command == 'exit': |
| break |
| print(f'输入的命令是{command}') |
| print('程序结束') |
| |
| for i in range(100): |
| command = input("请输入命令:") |
| if command == 'exit': |
| break |
| print(f'输入的命令是{command}') |
| print('程序结束') |
| while True: |
| command = input("请输入命令:") |
| if command == 'exit': |
| break |
| if command == 'cont': |
| continue |
| print(f'输入的命令是{command}') |
| print('程序结束') |
| list1 = [1,2,3,4,5,6] |
| list2 = [] |
| for num in list1: |
| list2.append(num*num) |
| |
| list1 = [1,2,3,4,5,6] |
| list2 = [num**2 for num in list1] |
| list1 = ['关羽','张飞','赵云','马超','黄忠'] |
| list2 = ['典韦','许褚','张辽','夏侯惇','夏侯渊'] |
| for member1 in list1: |
| for member2 in list2: |
| print(f'{member1} 大战 {member2}') |
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
· 提示词工程——AI应用必不可少的技术