In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Today, I will talk to you about the conditions of python to judge what the operation of if, elif and else is like. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
Today learn the conditional judgment of python if, elif, else operation.
First, create a new python file named py3_cond.py, and write the operation code in this file (the following is the code, which shows the running effect):
# simple if statement # judged to be true to execute code block content if True: print ("eager to learn Python!") # because it is False, if False: print ("not printed here") # A complete if elif else# code block lang = 'Python'#lang =' Java'if lang = = 'Python': print ("Hello" + lang) elif lang = =' Java': print ("Hello") + lang) elif lang = = 'Go': print ("Hello" + Go) else: print ("No Match!") # use and or not# for conditional judgment # and operation user =' yale'login_in = Trueif user = = 'yale' and login_in: print (' admin logins') else: print ('common logins') # or operation user = 'yale'login_in = Trueif user = =' yale' or login_in: print (' Admin logins') else: print ('common logins') # not operation login_in = Falseif not login_in: print ('Please logins') else: print ('login logins') # compare lista = [1 Magi 2 3] b = [1 id 2) 3] print (a = = b) # Trueprint (an is b) # False# because a b is two different objects in memory # the addresses of two variables are different print (id (a)) print (id (b)) # in the following case, it would be Truea = [1jue 2 3] b = aprint (id (a)) print (id (b)) # True# is the same object in memory print (an is b) # Python defaults to the value of False # False# None# "any empty sequence or list For example:'', (), []. # any empty mapping, for example: {} condition = Falseif condition: print ('True values') else: print (' False values')
The running effect of the above code:
After reading the above contents, do you have any further understanding of the condition of python to judge the operation of if, elif and else? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.