In: Computer Science
Pythons code using idle
Write an input function. Then use it to supply the input to following additional functions:
i) Print multiplication table of the number from 1 to 12.
ii) Print the sum of all the numbers from 1 to up the number given.
iii) Print if the number supplied is odd or even.
PYTHON CODE:
#function definitions
#function for multiplication table
def multiplication_table(num):
for i in range(1, 13):
print(f"{num}\tx\t{i}\t=\t{num*i}")
#function for summation
def summation(num):
summ=0
for i in range(1,num+1):
summ=summ+i
print(f"Sum (1 to {num}): {summ}")
#function for even or odd
def evenOdd(num):
if num%2==0:
print(f"{num} is even")
else:
print(f"{num} is odd")
#function to call other three functions
def input_func():
#taking input of number
n=int(input("Enter the number: "))
print()
multiplication_table(n) #function call
print()
summation(n) #function call
print()
evenOdd(n) #function call
#main
#function call
input_func()