File tree Expand file tree Collapse file tree 1 file changed +24
-6
lines changed
Expand file tree Collapse file tree 1 file changed +24
-6
lines changed Original file line number Diff line number Diff line change 2323#
2424# 茶叶:6包
2525
26- import numpy as np
26+ import numpy as np , time
2727
2828def solve_milk_tea_problem ():
2929 A = np .array ([[2 , 1 , 0 ],
@@ -33,16 +33,14 @@ def solve_milk_tea_problem():
3333 b = np .array ([10 , 1 , 2 ])
3434
3535 x = np .linalg .solve (A , b )
36- print ("解决方案是:" )
3736 print (f"奶昔:{ x [0 ]:.0f} 杯,巧克力奶茶:{ x [1 ]:.0f} 杯,柠檬绿茶:{ x [2 ]:.0f} 杯" )
3837
39- if __name__ == "__main__" :
40- solve_milk_tea_problem ()
41-
4238
4339import pandas as pd
4440import matplotlib .pyplot as plt
4541
42+
43+
4644def analyze_sales ():
4745 # Step 1: Create sales data
4846 data = {
@@ -74,7 +72,27 @@ def analyze_sales():
7472 plt .tight_layout ()
7573 plt .show ()
7674
75+ def range_test ():
76+ a = list (range (1000000 ))
77+ b = np .array (a )
78+
79+ # list
80+ start = time .time ()
81+ c = [x * 2 for x in a ]
82+ print ("list time:" , time .time () - start )
83+
84+ # numpy
85+ start = time .time ()
86+ d = b * 2
87+ print ("numpy time:" , time .time () - start )
88+
7789# Run the main function
7890if __name__ == "__main__" :
79- analyze_sales ()
91+ # analyze_sales()
92+ # solve_milk_tea_problem()
93+ # print(pd.__version__)
94+ # print(np.__version__)
95+ range_test ()
96+
97+
8098
You can’t perform that action at this time.
0 commit comments