1 ImportRandom2 3 """4 #查看源代码日后爬虫用5 Import Urllib.request6 7 # Coding=utf-88 9 url = "http://www.baidu.com"Ten data = Urllib.request.urlopen (URL). Read () One data = Data.decode (' UTF-8 ') A - print (data) - the # Print practiced hand - x = 5/2 - y = 3/2 - + print (' x = ', x, ' \ n ', ' y ', y) - print (' x and y are%.1f,%.1f '% (x, y) respectively) + A for z in range (1, one): at print (' {0:5d} {1:5d} {2:4d} '. Format (z, z * z, z * z * z)) - - print ("What??" + "Water") - Print (5 + 8) - """ - #If Else statement practiced hand in - toHelp ='big.' +HELP2 ='it's small.' -Gmanswer = 12450 theKey = Random.randint (1, 10) *Gmanswer =Key $Life = 3Panax Notoginseng - whileLife >0: theuseranswer = Int (input ('give me an integer .'))#converts the input str directly into int and assigns a value + ifUseranswer <Gmanswer: A Print(HELP2) the elifUseranswer >Gmanswer: + Print(Help) - Else: $ Print('You win') $ Break -Life-= 1
Beginner python (print use, conditional branching, loops, module references)