{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "81\n" ] } ], "source": [ "# Write a Python program to calculate the value of 'a' to the power 'b'.\n", "\n", "def power(a,b):\n", "\tif b==0:\n", "\t\treturn 1\n", "\telif a==0:\n", "\t\treturn 0\n", "\telif b==1:\n", "\t\treturn a\n", "\telse:\n", "\t\treturn a*power(a,b-1)\n", "\n", "print(power(3,4))" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.1" } }, "nbformat": 4, "nbformat_minor": 2 }