NewMrd
0
Q:

python random

# imports random
import random
# randint generates a random integar between the first parameter and the second
print(random.randint(1, 100))
34
# imports random
import random
# randint generates a random integar between the first parameter and the second
print(random.randint(1, 100))
# random generates a random real number in the interval [0, 1)
print(random.random())
19
#import random 
import random

names = ['Harry', 'John', 'Smith', 'Larry']

#print random name from names
print(random.choice(names))

#print random integer in a range of numbers
print(random.randint(1, 100)
6
import random
print(random.randint(0,1))
1
print(random.randint(1, 100))
print(random.random())
3
#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))
0
# I know somebody else has made a similar thing from mine.
# Just letting you know that I didn't mean to copy his idea for this code.
# If you saw this, I recommend check the other answers out, too.
# Hope you guys understand...
from random import randint

# Prints a random number in between 1 and 1000
print(f"Here is a random number: {randint(1, 1000)}")
1
from random import randint # Import randint from random
print(randint(1,20)) # Gets random number from first parameter to the second
0
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.")
0

New to Communities?

Join the community