当前位置:网站首页>Truth value and conditional expression
Truth value and conditional expression
2022-07-18 14:56:00 【qq_ forty-two million three hundred and seven thousand five hun】
if 100:
print(" Truth value ")
Conditional expressions selectively assign values to variables
#!/usr/bin/python
# -*- coding: UTF-8 -*-
sex = None
if input(" Please enter gender :") == " male ":
sex = 1
else:
sex = 0
print(sex)
sex = 1 if input(" Please enter gender :") == " male " else 0
print(sex)
""" 1. Get an integer if it is an even number as a variable state Assign even number, otherwise odd number 2. Enter the year. If it is a leap year, give the variable day assignment 28 otherwise 29 """
state = " Odd number " if int(input(" Please enter an integer :")) % 2 else " even numbers "
print(state)
year=int(input(" Please enter the year "))
day = 29 if year % 4 == 0 and year % 100 != 0 or year % 400 == 0 else 28
print(day)
边栏推荐
- 博云入选 Gartner 中国云管理工具市场指南代表厂商
- antd a-upload 多选multiple为ture时 限制上传个数
- 06-GuliMall 基础CRUD功能创建
- What if the self incrementing ID of online MySQL is exhausted?
- 求数据流中的中位数问题
- 2022年A特种设备相关管理(电梯)操作证考试题及在线模拟考试
- STM32应用开发实践教程:基于 RS-485 总线的多机通信应用开发
- The degradation mechanism is not designed properly, and the online system crashes instantly
- Family tree problem
- Uninstall cuda11.1
猜你喜欢

为什么电商平台要重点关注非法经营罪,这与二清又有什么关联?

Wechat Evaluation of applet design works Voting applet Graduation Design (5) Task Book

关于mock第三方调用

Deutsche Bank listed on the world Hong Kong Stock Exchange: with a market value of HK $3.9 billion, Shaanxi Automobile Group is the major shareholder

直线上最多的点数问题

分层自动化测试模型变与不变
![NC16857 [NOI1999]生日蛋糕](/img/40/95b3a62c829f352bd8e85943d01c5c.png)
NC16857 [NOI1999]生日蛋糕

小程序毕设作品之微信评选投票小程序毕业设计(7)中期检查报告

STM32应用开发实践教程:具备交互功能的人机界面应用开发

Xilinx FPGA 从spi flash启动配置数据时的地址问题
随机推荐
Constraints in vivado that you can't understand
[applet] attribute description and example of input box (text + code)
Wwdc22 - Apple privacy technology exploration
How to solve the problem of high concurrency? You will understand it completely after reading it.
分糖果系列问题
AcWing 3433. 吃糖果 递推|找规律
Network security experiment: firewall technology
00 后博士获聘南大特任副研究员,曾 4 岁上小学,14 岁考入南大!
WWDC22 - In App Purchase 更新总结
Top k high frequency elements
风控人不能不知的黑产大揭秘
求数据流中的中位数问题
The most points on a straight line
angr原理与实践(一)——原理
Sudo cannot find the command command not found solution
GEE(6):设置计算数值/影像保留小数位数
STM32应用开发实践教程:具备交互功能的人机界面应用开发
Wechat Evaluation of applet design works Voting applet Graduation Design (5) Task Book
2022 R2 mobile pressure vessel filling test questions and answers
Failed to determine a suitable driver class problem solution