当前位置:网站首页>Select statement if else
Select statement if else
2022-07-18 14:56:00 【qq_ forty-two million three hundred and seven thousand five hun】
Let the program execute the corresponding code according to the conditions
#!/usr/bin/python
# -*- coding: UTF-8 -*-
""" Select statement """
sex = input(" Please enter gender :")
if sex == " male ":
print(" Hello! , sir !")
elif sex == " Woman ":
print(" Hello! , ma'am !!!")
else:
print(" Unknown sex ")
Debugging code
Interrupt the program , Execute sentence by sentence and observe the execution process
1. Add breakpoint at pycharm Click in the code, and a small red dot will appear on the left. This is where you want to interrupt 
2. Right click on the debug Enter mode mode , Press f8 Execute the program step by step
#!/usr/bin/python
# -*- coding: UTF-8 -*-
price = int(input(" Single price of goods :"))
num = int(input(" The number of :"))
count_price = int(input(" Amount obtained :"))
price_1 = count_price - price * num
if price_1 >=0:
print(" Finally, it should be retrieved " + str(price_1))
# print(" The money is not enough ")
else:
print(" The money is not enough ")
# price_1 = count_price - price * num
# print(" Finally, it should be retrieved " + str(price_1))
""" Get a quarter Displays the corresponding month """
quarter = input(" Please enter quarter :")
if quarter == " In the spring ":
print("1,2,3")
elif quarter == " In the summer ":
print("4,5,6")
elif quarter == " autumn ":
print("7,8,9")
elif quarter == " In the winter ":
print("10,11,12")
a1 = float(input(" Input number :"))
a2 = input(" Please enter operator :")
a3 = float(input(" Input number :"))
if a2 == "+":
result = a1 + a3
print(result)
elif a2 == "-":
result = a1 - a3
print(result)
elif a2 == "*":
result = a1 * a3
print(result)
elif a2 == "/":
result = a1 / a3
print(result)
else:
print(" Operator error !!!")
num_1 = int(input(" Please enter a number :"))
num_2 = int(input(" Please enter a number :"))
num_3 = int(input(" Please enter a number :"))
num_4 = int(input(" Please enter a number :"))
# Suppose the first largest posterior surface is compared , Find larger alternative hypotheses
max_num = num_1
if max_num < num_2:
max_num = num_2
if max_num < num_3:
max_num = num_3
if max_num < num_4:
max_num = num_4
print(max_num)
#!/usr/bin/python
# -*- coding: UTF-8 -*-
""" Enter the score on the console to judge excellent / good / pass / fail, / Incorrect input """
result = int(input(" Please enter the grade :"))
if result < 0 or result > 100:
print(" Incorrect input ")
elif result >= 90:
print(" good ")
elif result >= 80:
print(" good ")
elif result >= 60:
print(" pass ")
elif 0 <= result:
print(" fail, ")
""" Enter the month to get the number of days """
month = int(input(" Please enter a month :"))
if month < 1 or month > 12:
print(" Incorrect input ")
elif month == 2:
print("28 God ")
elif month == 4 or month == 6 or month == 9 or month == 11:
print(30)
else:
print(31)
边栏推荐
- 小程序毕设作品之微信评选投票小程序毕业设计(7)中期检查报告
- Writing a new app with swift5 requires some considerations
- 通过装饰器获取调用函数的文件名称及函数名称
- Operation of simulated examination platform for 2022 G2 boiler stoker examination
- Please ask a question: does the flinkcdc need root permission to synchronize MySQL data?
- A series of questions about candy
- What if the self incrementing ID of online MySQL is exhausted?
- How does DMS empower database functions?
- Learning path PHP -- post can't get the requested data
- The secret of black industry that the risk controller cannot know
猜你喜欢

Wechat selection and voting of applet completion works applet graduation design (5) assignment

Family tree problem

Antd a-upload limit the number of uploads when multiple is true

Change and invariance of hierarchical automated test model

出海已成大势,技术如何赋能?| ArchSummit

【小程序】input输入框属性说明及示例(图文+代码)

直线上最多的点数问题

Xsslabs customs clearance

Uninstall cuda11.1

Fleet | "background exploration" issue 4: distributed transactions
随机推荐
2022年R2移动式压力容器充装试题及答案
Mitmproxy getting started installation
小程序毕设作品之微信评选投票小程序毕业设计(7)中期检查报告
配置MaskRCNN环境吐槽(GeForce MX250+win10+tensorflow1.5.0 GPU版)
Vulnhub-DC8学习笔记
Writing a new app with swift5 requires some considerations
小程序毕设作品之微信评选投票小程序毕业设计(5)任务书
AcWing 3619. Date date processing
2022 questions and answers of safety management personnel operation examination of hazardous chemical business units
AcWing 3652. Maximum continuous subsequence dynamic programming
【sdx62】SBL阶段读取GPIO的状态操作
06-GuliMall 基础CRUD功能创建
Please ask a question: does the flinkcdc need root permission to synchronize MySQL data?
Wechat Evaluation of applet design works Voting applet Graduation Design (5) Task Book
vivado里那些看不懂的约束语句
Redis报错MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist...
Antd a-upload limit the number of uploads when multiple is true
STM32应用开发实践教程:基于 CAN 总线的多机通信应用开发
Family tree problem
Hal firmware library