@@ -55,24 +55,24 @@ def generate_content() -> GenerateContentResponse:
5555 )
5656
5757 print ("# Code:" )
58- for part in response .candidates [0 ].content .parts :
59- if part .executable_code :
60- print (part .executable_code )
61-
58+ print (response .executable_code )
6259 print ("# Outcome:" )
63- for part in response .candidates [0 ].content .parts :
64- if part .code_execution_result :
65- print (part .code_execution_result )
60+ print (response .code_execution_result )
6661
67- # Example response:
6862 # # Code:
69- # code='\nimport random\n\ndef monty_hall_simulation(num_trials):\n
70- # """Simulates the Monty Hall problem and returns the win rates for switching and not switching."""\n\n
71- # wins_switching = 0\n wins_not_switching = 0\n\n for _ in range(num_trials):\n # 1. Set up the game:\n
72- # - Randomly place the car behind one of the three doors.\n car_door = random.randint(0, 2)\n
63+ # import random
64+
65+ # def monty_hall_simulation(num_trials=1000):
66+ # wins_switching = 0
67+ # wins_not_switching = 0
68+
69+ # for _ in range(num_trials):
70+ # # Randomly assign the car to a door (0, 1, or 2)
71+ # car_door = random.randint(0, 2)
7372 # ...
7473 # # Outcome:
75- # outcome=<Outcome.OUTCOME_OK: 'OUTCOME_OK'> output='Win percentage when switching: 65.90%\nWin percentage when not switching: 34.10%\n'
74+ # Win percentage when switching: 65.50%
75+ # Win percentage when not switching: 34.50%
7676 # [END googlegenaisdk_tools_code_exec_with_txt_local_img]
7777 return response
7878
0 commit comments