In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
What this article shares with you is about how to use conditional judgment sentences in Python. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
Code implementation
# conditional judgment statement (if statement) # Syntax: if conditional expression: # Code Block # process: when an if statement is executed, it evaluates the conditional expression first, # if it is True, the statement after if is executed # if it is False, it is not executed # by default, the if statement only controls the statement that follows it. If you want if to control multiple statements, # can be followed by a code block # code block # code block holds a set of code, code in the same block, either execute or not execute # code block is a mechanism for grouping code # if you want to write a code block, the statement cannot be followed by: Instead, write on the next line # the code block starts with indentation until the code returns to the previous indentation level # Lu Xun said: # there is no road in the world, so there will be more people walking! There are two ways to indent # xxxx# yyyy....#, one is to use the tab key, and the other is to use spaces (four). The official document of # Python recommends that we use spaces to indent. The indentation used in # Python code must be unified # "translate_tabs_to_spaces": true,# if False: print ('guess I came out?')
Num = 10if num > 10: print ('num is bigger than 10!') Print ('Nobody can control me')
If False: print (123) print (456) print (789) print (101112) print ('hello')
Num = 28
# you can use logical operators to connect multiple conditions. # if you want all conditions to be met at the same time, you need to use and#. If you want only one condition to be met, you need to use orif num > 10 and num < 20: print ('num is greater than 10, num is smaller than 20!')
Num = 15
If 10 < num < 20: print ('output: num is bigger than 10, num is smaller than 20!')
Code run output:
No one can control me.
Hello
Num is bigger than 10 and num is smaller than 20!
The above is how to use conditional judgment sentences in Python. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.