write a script to flip a coin
- User
write a script to flip a coin
Assistant
Sure! Here is a script to flip a coin:
codeimport random def flip_coin(): if random.randint(0, 1) == 0: return "heads" else: return "tails" print(flip_coin())This script uses the
randommodule to generate a random integer between 0 and 1. If the number is 0, it returns "heads", otherwise it returns "tails".You can run this script multiple times to flip the coin multiple times. For example:
code>>> flip_coin() 'heads' >>> flip_coin() 'tails' >>> flip_coin() 'heads'
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.