# Gimme5 - Random

Feb 11th, 2022
644
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. """
2. 1.  Create a program that produces a random integer between 15 and 35.
3.
4. 2.  Below is a list of five items of food, create some code that shuffles the list,
5. prints the shuffled list, then picks and prints one item at random.
6.     food = [“beans”,”cheese”,”tofu”,”cod”,”halumi”]
7.
8. 3.  Create a program that keeps asking for a random number between 1 and 52, until “xxx”
9. is entered and then tells you how many were even numbers and how many were odd numbers.  (hint below if needed)
10.
11. 4.  Take the list from Q2 and create a program that asks the user to enter a
12. new food item twice and then adds them to the list.  Then shuffles the list, removes the last item,
13. shuffles until the list is empty, print out the items removed each time. (hint below if needed)
14.
15. 5.  Create two lists, one of action words (verbs) and one of (fist_names).
16. Then create a program that selects a random item from each list, then concatenates them to give the
17. name of a new superhero and create five superhero names.  Append the names created to a new list.
18. """
19. """
20. #1
21. import random
22.
23. print(random.randint(15,35))
24. """
25. """
26. #2
27. import random
28.
29. food = ["beans","cheese","tofu","cod","halumi"]
30.
31. print(food)
32. random.shuffle(food)
33. print(food)
34.
35. print(random.choice(food))
36. """
37. """
38. #3
39. import random
40. even = 0
41. odd = 0
42. trig = ""
43. while trig != "xxx":
44.    trig = input("Press enter to get a random number >> ")
45.    if trig != "xxx":
46.        num = (random.randint(1,52))
47.        print(num)
48.        if num%2 == 0:
49.            even = even +1
50.        else:
51.            odd = odd +1
52. print(odd)
53. print(even)
54. """
55. """
56. #4
57. import random
58.
59. food = ["beans","cheese","tofu","cod","halumi"]
60. for i in range(2):
61.    new_item = input("Please enter new item >> ")
62.    food.append(new_item)
63.
64. for i in range(len(food)):
65.    print("BS",food)
66.    random.shuffle(food)
67.    print("AS",food)
68.    print("last item", food[-1])
69.    food.pop()
70. print(food)
71. """
72. """
73. # 5
74.
75. import random
76.
77. verb = ["running","sitting","crying","laughing","shouting"]
78. first_names = ["Henry","Claire","Clare","Sean","Jimbob","Hazel"]
79. super_heros = []
80.
81. for i in range(5):
82.    new_hero = random.choice(verb) + " " + random.choice(first_names)
83.    super_heros.append(new_hero)
84.    print(new_hero, super_heros)
85. """
86.