fork download
  1. def print_multiplication_table():
  2. try:
  3. # Take an integer input from the user
  4. number = int(input("Enter an integer: "))
  5.  
  6. # Print the multiplication table for the given number up to 10
  7. print(f"Multiplication table for {number}:")
  8. for i in range(1, 11):
  9. result = number * i
  10. print(f"{number} x {i} = {result}")
  11.  
  12. except ValueError:
  13. print("Please enter a valid integer.")
  14.  
  15. # Call the function to execute the program
  16. print_multiplication_table()
Success #stdin #stdout 0.03s 9792KB
stdin
2
stdout
Enter an integer: Multiplication table for 2:
2 x 1 = 2
2 x 2 = 4
2 x 3 = 6
2 x 4 = 8
2 x 5 = 10
2 x 6 = 12
2 x 7 = 14
2 x 8 = 16
2 x 9 = 18
2 x 10 = 20