In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
The knowledge of this article "Python uses random functions to generate changing graphics" is not understood by most people, so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article, let's take a look at this "Python uses random functions to generate changing graphics" article.
Question:
1. Whether the above programs can be optimized (such as those with the same function)
2. Create three three instances and use three statements. Can you create a function and automatically create n instances by entering only one number n? At the same time, the num_times of each instance is random, (when n is relatively large, the num_times should be small)
3. When the above functions are implemented, the program runs and only one parameter (the number of instances created) is entered, the corresponding num_times will be automatically generated, and the relevant functions will be called to generate the corresponding chart.
Yes, a multiplication formula is used to calculate the direction and moving position of each step in the class Rand_moving ().
X_direction = choice, 1 upward, 0 unchanged,-1 downward x_distance = choice, x_step = x_direction*x_distance # x per moving pixel, moving direction multiplied by moving distance To determine the direction of movement along x distance y_direction = choice ([1maimei 1]) # y, 1 up, 0 unchanged,-1 downward y_distance = choice ([0 mine1 min2 pencore 4 5]) # y, y_step = y_direction*y_distance # the moving direction multiplied by the moving distance to determine the distance moving along y
Therefore, we can sort out a calculation method, which can be called directly. As for 2Jing 3, it is obvious that it can also be done.
In the first step, the multiplication formula is proposed to form a separate method that acts on itself. The code is as follows:
Def get_step (self,direction,distance): return distance*direction def fill_moving (self): while len (self.x_values)
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.