Question

In: Computer Science

Q9) Write a function that asks the user for a number and prints out the multiplication...

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.

Solutions

Expert Solution

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


Related Solutions

Write a program that asks the user for an integer and then prints out all its...
Write a program that asks the user for an integer and then prints out all its factors. For example, when the user enters 84, the program should print 2 2 3 7 Validate the input to make sure that it is not a character or a string using do loop.in c++
Write a program that asks the user for an integer. The program checks and prints to...
Write a program that asks the user for an integer. The program checks and prints to the screen whether the number is prime or not. For example, if user enters 17, the program should print “17 is prime”; if the user enters 20, the program should print “20 is not prime”. please do it with a “ while Loop”, Thanks..
Write a short program that asks the user for a sentence and prints the result of...
Write a short program that asks the user for a sentence and prints the result of removing all of the spaces. Do NOT use a built-in method to remove the spaces. You should programmatically loop through the sentence (one letter at a time) to remove the spaces.
a). Write a program that asks the user to enter an integer N and prints two...
a). Write a program that asks the user to enter an integer N and prints two integers, root and power, such that 1 < power < 6 and N = root ** power. If no such pair of integers exists, it should print a message to that effect. There are two loops, one for power and one for root. Order the loops so that if N = 64, then your program find that N = 8 ** 2 rather than...
Write a program checkerboard3x3.cpp that asks the user to input width and height and prints a...
Write a program checkerboard3x3.cpp that asks the user to input width and height and prints a checkerboard of 3-by-3 squares. (It should work even if the input dimensions are not a multiple of three.) . Don't use function. Example 1: Input width: 16 Input height: 11 Shape: *** *** *** *** *** *** *** *** *** *** *** * *** *** * *** *** * *** *** *** *** *** *** *** *** *** *** *** * *** *** *...
Code in C ++ that asks the user for an integer and that prints whether or...
Code in C ++ that asks the user for an integer and that prints whether or not the number is divisible by three in the integers. If the number is not divisible by three, the program must write a message indicating what the remainder is obtained by dividing the number by three.
Write a program which prompts the user for a positive integer, and then prints out the...
Write a program which prompts the user for a positive integer, and then prints out the prime factorization of their response. Do not import anything other than the Scanner. One way you might go about this using nested loops: Start a "factor" variable at 2 In a loop: repeatedly print the current factor, and divide the user input by it, until the user input is no longer divisible by the factor increment the factor This plan is by no stretch...
Write a program that asks the user to enter an unsigned number and read it. Then...
Write a program that asks the user to enter an unsigned number and read it. Then swap the bits at odd positions with those at even positions and display the resulting number. For example, if the user enters the number 9, which has binary representation of 1001, then bit 0 is swapped with bit 1, and bit 2 is swapped with bit 3, resulting in the binary number 0110. Thus, the program should display 6. COMMENT COMPLETE CODE PLEASE
Write a mips program that would function in QTSPIM that asks the user to enter a...
Write a mips program that would function in QTSPIM that asks the user to enter a list of integer values, one per line, with the last value being a negative. The program should read in these integers until a negative number is entered. Afterwards the program should print 1) sum, 2) minimum value, 3) max value, 4) mean and 5) variance value. of the numbers that were entered.
Write code that takes the size of their foot from user and prints out suggested sandal...
Write code that takes the size of their foot from user and prints out suggested sandal size. Shoe Range Sandal Size <= 5 (inclusive) Small 5 ~ 9 (inclusive) Medium 9 ~ 12 (inclusive) Large above 12 X-Large example: Please enter your shoe size: (user types 6.5) Your sandal size is Medium.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT