random random code example

Example 1: python random

# imports random
import random
# randint generates a random integar between the first parameter and the second
print(random.randint(1, 100))

Example 2: random range python

from random import randrange
print(randrange(10))

Example 3: random in python

#Using Random choice python
#Running Race game
import time
import random
gamelist = ['You lose the race', 'You win the race']
Player = input('')
print(' Hi ' + Player + ' , welcome to the running race game')
time.sleep(2)
print('3')
time.sleep(1)
print('2')
time.sleep(1)
print('1')
time.sleep(2)
print(random.choice(gamelist))

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.")

Example 5: random

Welcome to your life as a wizard or witch. Make friends, trade knowledge of locations and spells. Forge your story...

Here are some of the spells to get your adventure started:
Expelliarmus
Sectumsempra
Lumos
Expecto Patronum
Anteoculatia
Orchideous
Tarantallegra

Teachers of the Wizard School, please do remember to teach that Q is used to block oncoming spells.

Example 6: random

Welcome to your life as a wizard or witch. Make friends, trade knowledge of locations and spells. Forge your story...

Here are some of the spells to get your adventure started:
Expelliarmus
Sectumsempra
Lumos
Expecto Patronum
Anteoculatia
Orchideous
Tarantallegra

Teachers of the Wizard School, please do remember to teach that Q is used to block incoming spells.

You need galleons to buy some spells like avada kedavra.