Class 9 Python QA 12-16
Class 9 Python QA 12-16
#user-defined function
A string is said to be a palindrome if
def myfunc(x): the reverse of the string is the same
return x==x[::-1] as the string.
#main function
num = int(input('Enter an integer number to find out the factorial: '))
result=factorial(num)
Enter an integer number to find out
print("Factorial of",num,"is",result) factorial: 4
Factorial of 4 is 24
15. Write a python program to access the list items using index.
OUTPUT
apple
banana
cherry
16. Write a python program to change the 2nd item with ‘mango’ using index.
OUTPUT
mango