In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Xiaobian to share with you what are the conditional statements in Python, I believe most people do not know how, so share this article for your reference, I hope you have a lot of gains after reading this article, let's go to understand it together!
if"" conditional statement: ifif... elseif... elif... elseif statement format: if condition: Condition holds Statement to be executed Condition: Operator composition---> bool""print(1)print(2)result = input ('please input (y/n):') if result == 'y': print('good~')print('-'*20)if…elseif... Form of statement: if condition: The condition holds for the statement to be executed else: Statements executed when the condition does not hold
Exercise:
#random number import randomram = random. randomint (1, 10)guess = input("Please enter your guess: ")if ram == int(guess): print ('guess right') else: print ('guess wrong') if…elif…elseif... elif... else format if Condition 1: Condition 1 holds the statement to be executed elif Condition 2: Statement executed when condition 2 holds elif condition 3: The statement executed when condition 3 holds else: Practice when conditions 1, 2 and 3 are not met: #Personnel Management System #Functions: Add employees, delete employees, query employees, modify employee information. print ('-'*20, ' Welcome to Personnel Management System','-'*20)choice = input ('Please select function: \n1.Add employees\n2.Delete employees\n3.Query employees\n4.Modify employee information\n')#Compare choices one by one if choice == '1': print ('Add employee') elif choice == '2': print ('delete employee') elif choice == '3': print ('query employee') elif choice == '4': print ('Modify employee information') else: print ('typo ') The above is "What are conditional statements in Python" All the contents of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to 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.