Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Dice roll and coin flip

import random

def dice_roll():
  return random.randint(1, 6)
  
def coin_flip():
  if random.randint(1, 2) == 1:
    return 'heads'
  else:
    return 'tails'
Comment

PREVIOUS NEXT
Code Example
Python :: py2exe no console 
Python :: r named chr to dataframe 
Python :: python number of elements in list of lists 
Python :: array of objects in python 
Python :: os.move file 
Python :: how to return a value from a function in python 
Python :: python codes 
Python :: delete last message discord.py 
Python :: how to end an infinite loop in specific time python 
Python :: Creating and writing to a new file 
Python :: how to code a yes or no question in python v3.8 
Python :: append a list to a list python 
Python :: len function in python 
Python :: yield python 
Python :: python type hinting pandas dataframe 
Python :: python crash course 
Python :: replace nan using fillna 
Python :: python gzip a file 
Python :: python PyDrive service account credentials 
Python :: python print date, time and timezone 
Python :: sorting algorithms in python 
Python :: get filename from path python 
Python :: funcions in python 
Python :: python get screen size raspberry pi 
Python :: How do you create an matrix of random integers in Numpy? 
Python :: python recursion factorial 
Python :: python returned non-zero exit status 1. 
Python :: arrayfield in django 
Python :: selenium do not open browser window 
Python :: urllib.request.urlopen with headers 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =