1 #Encoding:utf-82 3 4 #print 10 times Hello word5num = 106 whilenum >0:7 Print("Hello Word")8num-= 19 Ten #Invert string OneMessage ="Hello Word" Aresult ="" - forCinchmessage: -result = C +result the Print(Result) - - #print even numbers from 0 to 100 - forNuminchRange (0, 101): + ifNum% 2 = =0: - Print(Num,"even") + A #from 1 to 100 and atTotal =0 - forNuminchRange (1, 101): -Total + =Num - Print(total) - - #the loop inputs two values, evaluates and in #ask if you want to jump out of loops - #add to input value to whileTrue: +a = Int (input ("Please enter the first value:")) -b = Int (input ("Please enter a second value:")) the #determine if the input value meets the criteria * if(0 < A < 100)or(0 < b < 100): $ Print("There is a problem with the value you entered, please re-enter")Panax Notoginseng Continue -Total = a +b the #Output and + Print("the two values are:", total) A #Ask the user if they want to quit theIsQ = input ("do you want to exit (yes: Q No: Enter):") + ifIsQ = ="Q": - Break $ $ #Print multiples of 3 in 1 to 100 - forNuminchRange (1, 100): - ifNum% 3 = =0: the Print(num) - Wuyi #Print 99 multiplication table the forIinchRange (1, 10): - forJinchRange (1, i + 1): Wu Print("%d *%d =%d"% (J, I, J * i), end="\ t") - Print("\ n") About $ #Judging the number of daffodils - #hundreds of three of times, 10 bits of three square, bits of the sum of three square equals the number itself - whileTrue: -num = Int (input ("Please enter a three-digit number:")) A if not(<= num <= 999): + Print("the number is not a three-digit number, please re-enter") the Continue - #find the Hundred, 10 digits, single digit $Bai_wei = num//100 theShi_wei = num% 100//10 theGe_wei = num% 10 the Print(Bai_wei) the Print(Shi_wei) - Print(Ge_wei) in #determine if the number of daffodils is the ifBai_wei * * 3 + Shi_wei * * 3 + Ge_wei * * 3 = =Num: the Print("%d is the number of daffodils"%num) About Else: the Print("%d is not the number of daffodils"%num) the the #Guessing Games + #The program internally defines a data that the user enters in a 500 data - #If the user guesses right, prompts correctly and exits the #if it's wrong, the hint is big or small and guess again.Bayinum = 123 theCount =0 the whileTrue: -result = Int (input ("Please enter the result of the guess:")) -Count + = 1 the if not(0 <= Result <= 500): the Print("There is a problem with the value entered, please re-enter") the Continue the - ifresult = =Num: the Print("guess right, you've guessed%d times."%count) the Break the Else:94 ifResult >Num: the Print("guess it's big, please re-guess") the Else: the Print("guess small, please re-guess")
Python | Cycle