2. import random
WORDS = ("python", "jumble", "easy", "difficult", "answer" "xylophone")
word = random.choice (WORDS)
correct = word
jumble = ""
while word:
position = random.randrange (len(word) )
jumble += word[position]
word = word[:position] + word[(position + 1):]
print(
"""
welcome to word jumble!
Unsramble the letters to make a word.
(press the enter key at the prompt to quit.)
"""
)
print("The jumble is:", jumble)
guess = input ("nYour Guess: ")
while guess != correct and guess != "":
print("Sorry, that's not it.")
guess = input ("your guess: ")
print ("Thanks for playing.“)
WHILE LOOP
3. # Mood Computer
# Demonstrates the elif clause
import random
print("I sense your energy. Your true emotions are coming across my screen.")
print("You are..")
mood = random.randint(1, 3)
if mood == 1:
# happy
print (
""" :D """)
elif mood == 2:
# neutral
print (
""" -_- """)
elif mood == 3:
# sad
print (
""" :( """)
else:
print("Illegal mood value! (You must be in a really bad mood).")
print ("....today")
input("nnPress the enter key to exit.")
IF LOOP
4. message = input("Enter Message: ")
print("nThe length of your message is:", len(message) )
print("n the most common letter in the english language is, 'e', ")
if "e" in message:
print("is in your message.")
else:
print("is not in your message.")
IF ELSE LOOP