#1. Write a program that asks the user to enter a letter. Then it generates a random number between 1 and 10 and prints out the letter that many times.
import random
letter=input("Enter a letter")
r = random.randint(1,10)
for a in range(r):
print(letter)
Enter a letterS S S S S
#2. In the game Yahtzee, players roll five dice. A Yahtzee is when all five dice are the same. Write a program that simulates rolling five 10,000 times and counts how many Yahtzees occur. Print out what percentage of the rolls come out to be Yahtzees.
from random import randint
yahtzee = 0
for a in range(10000):
x = random.randint(1,6)
y = random.randint(1,6)
z = random.randint(1,6)
m = random.randint(1,6)
n = random.randint(1,6)
if(x==y==z==m==n):
yahtzee +=1
else:
pass
percentage = (yahtzee/10000)*100
print("percentage of rolls come out is: ", percentage)
percentage of rolls come out is: 0.04
#3. Write a program that asks the user to enter a sentence, removes all the spaces from the sentence, converts the remainder to uppercase, and prints out the result.
s=input("Enter a Sentence")
x = s.replace(" ", "")
str.upper(x)
Enter a Sentencejntuh college of engineering
'JNTUHCOLLEGEOFENGINEERING'
# 4. Write a program that asks the user to enter a string. If the string is at least five characters long, then create a new string that consists of the first five characters of the string along with three asterisks at the end. Otherwise add enough exclamation points (!) to the end of the string in order to get the length up to five.
s=input("Enter a string")
l=len(s)
a=5-l
s1 = '!'
if l >=5:
new = s[:5] + ('***')
else:
new = s[:] + (s1*a)
print(new)
Enter a stringJNTU JNTU!
# 5. Write a program that ask the user to enter a string that consists of multiple words. Then print out the first letter of each word, all on the same line.
str1=input("Enter a string with multiple of words")
str2=str1.split(' ')
i=0
for i in str2:
print(i[0],end='')
Enter a string with multiple of wordsJntuh College of Engineering JCoE