import random robot_1_win_count = 0 robot_2_win_count = 0 match_rounds = 0 while match_rounds < 10: #assign strength to robots robot_1 = random.randint(1,100) robot_2 = random.randint(1,100) match_rounds = match_rounds + 1 if (robot_1 > robot_2): robot_1_win_count = robot_1_win_count + 1 else: robot_2_win_count = robot_2_win_count + 1 if(robot_1_win_count > robot_2_win_count): print("Robot_1 wins with " + str(robot_1_win_count) + " victories!") else: print("Robot_2 wins with " + str(robot_2_win_count) + " victories!")
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question