Python Code Snippets

Below are some useful Python code snippets for use in everyday projects.

Generate Random Number Between Two Values

Here is an example of how to generate a random number between two values, in this case 1 and 59, then display it.

import random

# Minimum and maximum values for random number.
min_val = 1
max_val = 59

# Generate random number.
random_number = random.randint(min_val, max_val)

# Display the number in the console/terminal.