Write a function to print the table of a given number. The number has to be entered by the user.
Question
Write a function to print the table of a given number. The number has to be entered by the user.
✨ Free AI Tools for You
Powered by Chatterbot AI
Answer
Here's the Python function to print the multiplication table of a given number entered by the user:
def print_multiplication_table():
num = int(input("Enter a number to print its multiplication table: "))
for i in range(1, 11):
print(f"{num} x {i} = {num * i}")
You can call this function, and it will prompt you to enter a number and then print the multiplication table for that number from 1 to 10.
India's 1st AI Doubt Solver for CBSE, JEE, and NEET
Ask a Question for Freeand then it's just ₹212 a month