In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "how to realize the single loop of Python full stack". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
1. Polyterm_Nested Branches
Multiple branches (multiple choice)
"""if conditional expression 1: code1 elif conditional expression 2: code2elif conditional expression 3: code3else: if conditional expression 1 is true, execute the corresponding branch code1; otherwise, judge whether conditional expression 2 is true; if conditional expression 2 is true, execute the corresponding branch code2; otherwise, judge whether conditional expression 3 is true; if conditional expression 3 is true, execute the corresponding branch code3; if not, directly take the else branch, elif can be 0 or more else can be 0 or one ""youqian = Falseyoufang = Falseyouche = Falseif youqian == True: print("This person is very powerful")elif youfang == True: print("Can I give it to a friend")elif youche == True: print("Open the Yadima transfer car, let's touch it") else: print("You'd better be a Meituan rider")print("")# ##nested branches "" Single branch, bidirectional branch, nested combination of multiple branches ""youqian = Truyoufang = Trueyouche = Trueyouyanzhi = Trueyoutili = Falseif youqian == True: if youfang == True: if youche == True: if youyanzhi == True: if youtili == True: print("I want to marry you ~") else: print("Go eat some big kidneys and come back ~") else: print("You go to Thailand + Korea, plastic surgery")else: print("You're a good person ~") print("")#question height#girl looking for a partner #Boys are between 1 meter and 1.5 meters. Xiaoqiang, where are you? #Boys don't feel safe between 1.5 and 1.7 meters ~ #Boys between 1.7 and 1.8 meters, handsome guys leave a phone number #Boys between 1.8~2 meters, handsome, do you suggest one more girlfriend # python unique (note: because input accepts strings, and because we enter decimals, we can only use float here)""height = float(input("please enter your height:"))if 1 i = 2 second loop i = 2 i total = total + i => 0 + 1 + 2i += 1 => i = 3 third loop i = 3 i total = total + i => 0 + 1 + 2 + 3 i += 1 => i = 4... And so on when i = 101 101 total + i => 0 + 1 + 2 + 3 + 4 +... + 100 => 5050"""#endless loop""while True: print(1)""# ####Use the endless loop method to realize 1 ~ 100 accumulation sum i = 1total = 0sign = Truewhile sign: total += i i+=1 #Determine if i is added to 101 , do not participate in the loop if i == 101: #End the cycle sign = Falseprint(total) #1 ~ 100 = 50502.2 Exercise for a single loop # (1) Print a line of ten small stars * help(print)# help View documentation for a method help(print)""# print ("*",end='')# print ("*",end='')# print ("*",end='')# print ("*",end='')# print("*",end='')# print("*",end='')# print("*",end='')# print("*",end='')# print("*",end='')# print("*",end='')"""i = 0while i
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.