In: Computer Science
Q9) Write a function that asks the user for a number and prints
out the multiplication table for that number. Python3
Q10)Write a function that takes two integer inputs for width and
length, and prints out a rectangle of stars. (Use * to represent a
star).
Q11)Write a program that reads in a string and prints whether it: [Hint: given a character like ‘H’ you can apply to it the method ‘H’.isalpha() to check if it is a letter or ‘H’.isdigit() to check if it is a number. Clearly the latter returns False and the former returns True] • contains only letters • contains only uppercase letters • contains only lowercase letters • contains only digits • contains only letters and digits 1 • starts with an uppercase letter • ends with a period.
9) fUNCTION TO PRINT THE MULTIPLICATION TABLE
def multiplication(n):
for i in range(1,11): #loop runs from 1 to 10
print(n,"*",i,"=",n*i);#print the multiplication table
PROGRAM IN PYTHON 3
def multiplication(n):
for i in range(1,11): #loop runs from 1 to 10
print(n,"*",i,"=",n*i);#print the multiplication table
#read a number from user
n = int(input("Enter the number"));
multiplication(n)#call to function to print the multiplication
table
PROGRAM IN JPEG FORMAT WITH OUTPUT
10)
def rectangle(m,n):
for i in range(1,m+1): #loop runs from 1 to m for width
for j in range(1,n+1): # loop runcs from 1 to n for length
print(" * ",end=" ");#print * in rows
print() #generate a new line
#read a length and width from user
m = int(input("Enter the width"));
n = int(input("Enter the length"));
rectangle(m,n)#call to function to print the rectangle
output
program in jpeg format