Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

random.choices in python

import random
s = ['Apple', 'Orange', 'Banana']

# print any random value from the list s
print(random.choice(s)) # output 'Apple'

# type of value does not matter
s = ['Apple', 'Orange', 'Banana', 13, 3, 1.513, 5413, '1341']
print(random.choice(s)) # output: 1.513
Comment

PREVIOUS NEXT
Code Example
Python :: python gui 
Python :: turn columns into one column as list python 
Python :: tkinter background image python 3 
Python :: importing python module from different directory 
Python :: Python Date object to represent a date 
Python :: dataframe fill nan with mode 
Python :: python logo png 
Python :: pandas apply check for string length in column 
Python :: basic string functions in python 
Python :: seaborn distplot 
Python :: split pdf python 
Python :: install poetry on linux 
Python :: logging.basicConfig() 
Python :: creating an apis with python and flask 
Python :: remove decimal python 
Python :: reading a file line by line using a generator 
Python :: how to change values of dictionary in python 
Python :: bubble sort with code optimization 
Python :: random.uniform python 
Python :: get file parent directory python 
Python :: scrapy shell 
Python :: python regex to find year 
Python :: display multiple dataframe as table jupyter notebook 
Python :: create a python api 
Python :: open url from ipywidgets 
Python :: python for web development 
Python :: pysimplegui themes 
Python :: read an excel file 
Python :: how to install python library 
Python :: jupyter notebook spark 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =