Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

random picker in python

import random
#dictionary
x_dict = {30:60, 20:40,10:20}
key = random.choice(list(x_dict))
print (key)#if you want it to print 30, 20, or 10
print (x_dict[key])#if you want it to print 60, 40, or 20
print (key,"-", x_dict[key])# if you want to print 30 - 60, 20-40,or 10-20
Comment

Random Picker Python

import random

print(random.randint(15, 30)) #Prints a number from 15 to 30 after picking a random number from 15 to 30
RandomNumber = random.randint(0,100)
print(RandomNumber)
Comment

PREVIOUS NEXT
Code Example
Python :: convert python float list to 2 digit 
Python :: python replace only first instance 
Python :: iter() python 
Python :: pip in vscode linux 
Python :: type string python 
Python :: difference between for loop and while loop in python 
Python :: python series to list of string 
Python :: combine dataframes with two matching columns 
Python :: how to iterate over columns of pandas dataframe 
Python :: python find duplicates in string 
Python :: rmse python 
Python :: how to calculate z score in python 
Python :: selenium open inspect 
Python :: count down for loop python 
Python :: how do i turn a tensor into a numpy array 
Python :: Write a Python program to count the number of lines in a text file. 
Python :: pygame rotate image 
Python :: create app in django 
Python :: 3 dimensional array in numpy 
Python :: python count array length 
Python :: django python base 64 decode 
Python :: how to make a python function 
Python :: find duplicated entries present in a list 
Python :: flatten columns after pivot pandas 
Python :: python remove all elemnts in list containing string 
Python :: what is the difference between tuples and lists in python 
Python :: how to multiply a string in python 
Python :: python aes encryption 
Python :: pandas average every n rows 
Python :: python getattr 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =