-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandom.py
More file actions
31 lines (22 loc) · 780 Bytes
/
Random.py
File metadata and controls
31 lines (22 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import random as rd
print(rd.random())
print(rd.randint(1, 6))
print(rd.randrange(10, 100, 10))
print(rd.uniform(2, 3))
print()
animals = ["\N{cat}", "\N{dog}", "\N{snake}", "\N{horse}"] # Prints emojis / works in web
rd.shuffle(animals)
print(animals)
print()
heroes = ['Batman', 'Captain America', 'Spiderman', 'Ironman']
villians = ['Joker', 'Red Skull', 'Venom', 'Thanos']
rd.shuffle(heroes)
rd.shuffle(villians)
for i in range(4):
print(heroes[i], 'VS', villians[i])
print()
students = ['a', 'b', 'c', 'd', 'e']
probability = [0.3, 0.3, 0.1, 0.1, 0.2] # chances of appearance
print(rd.choices(students, probability, k=3)) # k mean how many values, can be more than len of list
print()
print(rd.sample(range(10), k=3))