In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what are the basic Python exercises". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "what are the basic Python exercises?"
1. Enter a percentile score
The output grades A, B, C, D, E are required, in which 90 minutes 100 points are A _ (80) ~ 89 points, B _ (70) _ 79 points are C _ (60) _ 69 points, and below 60 points are E.
Request:
Implemented with if statement
The rationality of the score should be judged after entering the score of the percentile system, and the error information should be output for the unreasonable score.
Code:
A=eval (input ('Please enter score:') if a100 or a% 1 grade 0: print ('the result you entered is unreasonable, please check and re-enter') elif 90 > > len (A) > B=print (A [:: 3]) > > C=print (A [::-1]) > > D=print (A [: 3] + C [- 5:]) 12. Format the scientific representation corresponding to the output 0.002178 respectively
Format the scientific representation form, floating point form and percentage form corresponding to output 0.002178, respectively, and set the output width to 10, center alignment, and asterisk * filling.
Code:
X=0.002178print ("x" corresponding to the scientific representation is: ", ("% e "% x) .center (10 quotes)) print (the floating-point form of'x with 4 decimal precision is:', ('{0ve.4f} '.format (x)) .center (10cm percentile') print ('x percentage form is:', ('{0lle.2f}% 'format (xscore 100)) .center (10cm percentile)
Output:
The corresponding scientific representation of x is: 2.178000e-03
The floating point form of x with 4 decimal precision is: * * 0.0022 decimal *
The form of x percentage is: * 0.22% percentage *
13. Write a program
Enter a 1-7 number from the keyboard and format the week string name of the corresponding number. For example, enter 3 and return "what you entered is Wednesday".
Code:
N = int (input ('enter a number of 1 to 7:') if (Monday): print ("you entered Monday") elif (Monday): print ("you entered Tuesday") elif (Tuesday 3): print ("you entered Wednesday") elif (Thursday 4): print ("you entered Thursday") elif (Friday 5): print ("you entered Friday") elif ("you entered Friday") Print ("you entered Saturday") elif (Sunday 7): print ("you entered Sunday")
Output:
Enter a number 3 from 1 to 7
You entered Wednesday.
14. Digital encryption game
In the programming program, enter a 4-digit number arbitrarily from the keyboard, multiply each number in the number by 7, then take the single digit of the product result to replace the number, and finally get a new 4-digit number.
Code:
N = int (input ('enter any 4 digits:') if 1000
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.