Skip to content

Instantly share code, notes, and snippets.

@ayubmetah
Created December 20, 2020 06:11
Show Gist options
  • Save ayubmetah/25dbad310b5462220e2df40d2c83a279 to your computer and use it in GitHub Desktop.
Save ayubmetah/25dbad310b5462220e2df40d2c83a279 to your computer and use it in GitHub Desktop.
Multiplication table in Python
#This function prints out a multiplication table (where each number is the result of multiplying the first number of its row by the number at the top of its column). Fill in the blanks so that calling multiplication_table(1, 3) will print out:
#1 2 3
#2 4 6
#3 6 9
def multiplication_table(start, stop):
for x in range(start,stop+1):
for y in range(start,stop+1):
print(str(x*y), end=" ")
print()
multiplication_table(1, 10)
# Should print the multiplication table shown above.
@Joaking95
Copy link

def multiplication_table(start, stop):
for x in range(start+2):
x = x + 1
for y in range(stop):
y = y +1
print(str(x*y), end=" ")

	print()

multiplication_table(1, 3)

Should print the multiplication table shown above

@leszen
Copy link

leszen commented Jan 22, 2023

def multiplication_table(start, stop):
for x in range(start, stop+1):
for y in range(start, stop+1):
print(str(x*y), end=" ")
print()

multiplication_table(1, 3)

Should print the multiplication table shown above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment