Practice 1
English units and metric units switch
"" " English units inch and metric units cm interchangeably versoin 0.1 author Luo Xu as " "" value = a float (INPUT ( ' Enter length values: ' )) Unit = INPUT ( ' Enter Unit: ' ) IF Unit == ' in ' or Unit == ' inch ' : Print ( ' % F =% f inches cm ' % (value, value * 2.54 )) elif Unit == ' cm & lt ' or Unit == ' cm ' : print('% f% f cm = inches ' % (value, value / 2.54 )) the else : Print ( " Please enter a valid unit ' )
Practice 2
Dice to decide what to do
"" " ' Craps Version 0.1 author to Luo Xu " "" # using the random function module generates a random number randint specified range from random Import randint face = randint (1,6 ) IF face. 1 == : Result = ' balabla ' elif face == 2 : Result = ' kalakala ' elif face ==. 3 : Result = ' daladala ' elif face ==. 4 : Result = 'iaoaiaoa ' elif face==5: result='jojojojo' else: result='didadida' print(result)
Practice 3
Percentile turn hierarchy
"" " Percentile transfer hierarchy Version 0.1 author Luo Xu as " "" Score = float (the INPUT ( ' Please enter the result: ' )) IF Score> = 10 : Grade = ' too show it ' the else : IF Score == 100 : Grade = ' learn God ' elif Score> = 85 : Grade = ' learning Pa ' elif Score> = 70 : Grade = ' Science China ' elif score >= 60: Grade = ' learn weak ' elif socre> = 45 : Grade = ' Science slag ' the else : Grade = ' Science residues ' Print (Grade)
Practice 4 Analyzing the triangle area and calculating the perimeter and
"" " Side length of triangular configuration determines whether the input if it is possible to calculate the triangles constituting the triangular perimeter and the area " "" Import Math A = a float (INPUT ( ' A = ' )) B = a float (INPUT ( ' B = ' )) C = a float (INPUT ( ' C = ' )) IF A + B> C and A + C> B and B + C> A: Print ( ' circumference:% F ' % (A + B + C) ) P = (A + B + C) / 2 Area = Math.sqrt (P * (PA) * (Pb) * (p- C)) Print ( 'Area:% f' % Area) the else : Print ( ' can not form a triangle ' )
Practice 5 Personal Income Tax Calculator
"" " Personal Income Tax Calculator Version 0.1 author Luo Xu as " "" salary = float (the INPUT ( ' monthly income is: ' )) Insurance = float (the INPUT ( ' five insurance payments: ' )) diff = salary-Insurance-3500 IF the diff <= 0: Rate = 0 for deductible = 0 elif the diff <1500 : Rate = 0.03 for deductible = 0 elif the diff <4500 : Rate = 0.1 for deductible = 105 elif the diff <9000: rate=0.2 deduction=555 elif diff<35000: rate=0.25 deduction=1005 elif diff < 55000: rate = 0.3 deduction = 2755 elif diff<80000: rate=0.35 deduction=5505 else: rate=0.45 deduction=13505 tax=abs(diff*rate-deduction) print('个人所得税:¥%.2f元'%tax) print( ' Actual hand income: ¥% .2f RMB ' % (diff + 3500-Tax))
******************************
Today, parts of the code practice
Today is also full of vitality trainee
******************************