randomise in python code example
Example 1: random numbers python
import random
a = (random.randint(bottom value, top value)
Example 2: how to import random in python
import random
Example 3: python random
from random import randint
print(f"Here is a random number: {randint(1, 1000)}")
Example 4: random.random in python
enota = input("V kateri enoti boš podal temperaturo? Vnesi 'C' ali 'F': ")
stopinje = int(input("Število stopinj: "))
if enota != "C" and enota != "F":
print("Vnesi ustrezno enoto.")
else:
if enota == "C":
odg = int(round((9 * stopinje) / 5 + 32))
nova_enota = "Fahrenheit"
elif enota == "F":
odg = int(round((stopinje - 32) * 5 / 9))
nova_enota = "Celzija"
print("Temperatura v stopinjah", nova_enota, "je", odg, "stopinj.")