ans1 import random letter = input("Enter a letter: ") random_number = random.randint(1, 10) output = letter * random_number print(output) ------------------------------------------------------------------------------------ ans 2 import random num_rolls = 10000 yahtzee_count = 0 for _ in range(num_rolls): dice = [random.randint(1, 6) for _ in range(5)] # Roll five dice if len(set(dice)) == 1: # Check if all dice have the same value yahtzee_count += 1 percentage = (yahtzee_count / num_rolls) * 100 print(f"Percentage of Yahtzees: {percentage:.2f}%") -------------------------------------------------------------------------------------- ans 3 sentence = input("Enter a sentence: ") # Remove spaces from the sentence sentence_without_spaces = sentence.replace(" ", "") # Convert the sentence to uppercase uppercase_sentence = sentence_without_spaces.upper() print(uppercase_sentence) --------------------------------------------------------------------------------------- ans 4 input_string = input("Enter a string: ") if len(input_string) >= 5: new_string = input_string[:5] + '***' else: exclamation_points = '!' * (5 - len(input_string)) new_string = input_string + exclamation_points print(new_string) -------------------------------------------------------------------------------------- ans 5 sentence = input("Enter a string consisting of multiple words: ") # Split the sentence into individual words words = sentence.split() # Extract the first letter of each word and concatenate them first_letters = "" for word in words: first_letters += word[0] print(first_letters)