PYTHON PROGRAMMING 10

 

separator-blank.png

 

PART 3 – RANDOM NUMBERS

 

PROGRAMS

 

PROGRAM 1 – RANDOM NUMBERS

 

import random
 
d10 = random.randint(1, 10)
print(d10)

 

 

TASK 1

 

Write a program that simulates the rolling of two 6-sided die and outputs their value as well as their total.

 

SAMPLE IO

 

You rolled a 4 and a 2.

Total: 6

 

PROGRAM 2 – RANDOM ADJECTIVE

 

import random
 
rn = random.randint(1, 3)
 
if rn == 1:
    adj = "cool"
elif rn == 2:
    adj = "strange"
else:
    adj = "different"
 
print("You are very", adj + ".")

 

 

TASK 2

 

Write the program called Which avenger are you? that will randomly assign you the name of one of the Avengers.  Your program should have at least 5 different names to choose from.

 

SAMPLE IO

 

You are Thor.

SAMPLE IO 2

 

You are Black Widow.

 

separator-blank.png