1. Write code for to print multiplication table with given input.
# function with argument
def multiplication_table(num, up_to):
result_list = []
for i in range(up_to + 1):
result = num * i
result_list.append(f"{num} x {i} = {result}")
return result_list
# Example usage:
num = 5
up_to = 10
table_results = multiplication_table(num, up_to)
# Print the results
for result in table_results:
print(result)
# function with argument
def multiplication_table():
num = int(input('enter num: '))
up_to = int(input('upto which value you want: '))
result_list = []
for i in range(up_to + 1):
result = num * i
result_list.append(f"{num} x {i} = {result}")
return result_list
table_results = multiplication_table()
# Print the results
for result in table_results:
print(result)
# procedure with argument
def multiplication_table(num, up_to):
for i in range(up_to + 1):
result = num * i
print(f"{num} x {i} = {result}")
# Example usage:
multiplication_table(2,4)
# procedure without argument
def multiplication_table():
num = int(input('enter num: '))
up_to = int(input('upto which value you want: '))
for i in range(up_to + 1):
result = num * i
print(f"{num} x {i} = {result}")
multiplication_table()
# function with argument
def isPalidrome(n):
temp = n
reverse_num=0
while n >0:
digit= n% 10
reverse_num = reverse_num * 10 + digit
n = n // 10
if temp == reverse_num:
return True
else:
return False
result = isPalidrome(55)
if result:
print('is palindrome')
else:
print('not palindrome')
# function without argument
def isPalidrome():
n = int(input('enter num: '))
temp = n
reverse_num=0
while n >0:
digit= n% 10
reverse_num = reverse_num * 10 + digit
n = n // 10
if temp == reverse_num:
return True
else:
return False
result = isPalidrome()
if result:
print('is palindrome')
else:
print('not palindrome')
# procedure without argument
def isPalindrome():
n = int(input('enter num: '))
temp = n
reverse_num=0
while n >0:
digit= n% 10
reverse_num = reverse_num * 10 + digit
n = n // 10
if temp == reverse_num:
print(f"{temp} is a palindrome.")
else:
print(f"{temp} is not a palindrome.")
isPalindrome()
# procedure with argument
def isPalindrome(n):
temp = n
reverse_num = 0
while n > 0:
digit = n % 10
reverse_num = reverse_num * 10 + digit
n = n // 10
if temp == reverse_num:
print(f"{temp} is a palindrome.")
else:
print(f"{temp} is not a palindrome.")
isPalindrome(444)
Comments
Post a Comment