{ "cells": [ { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import math" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['__doc__',\n", " '__loader__',\n", " '__name__',\n", " '__package__',\n", " '__spec__',\n", " 'acos',\n", " 'acosh',\n", " 'asin',\n", " 'asinh',\n", " 'atan',\n", " 'atan2',\n", " 'atanh',\n", " 'ceil',\n", " 'copysign',\n", " 'cos',\n", " 'cosh',\n", " 'degrees',\n", " 'e',\n", " 'erf',\n", " 'erfc',\n", " 'exp',\n", " 'expm1',\n", " 'fabs',\n", " 'factorial',\n", " 'floor',\n", " 'fmod',\n", " 'frexp',\n", " 'fsum',\n", " 'gamma',\n", " 'gcd',\n", " 'hypot',\n", " 'inf',\n", " 'isclose',\n", " 'isfinite',\n", " 'isinf',\n", " 'isnan',\n", " 'ldexp',\n", " 'lgamma',\n", " 'log',\n", " 'log10',\n", " 'log1p',\n", " 'log2',\n", " 'modf',\n", " 'nan',\n", " 'pi',\n", " 'pow',\n", " 'radians',\n", " 'sin',\n", " 'sinh',\n", " 'sqrt',\n", " 'tan',\n", " 'tanh',\n", " 'tau',\n", " 'trunc']" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dir(math)" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Help on built-in module math:\n", "\n", "NAME\n", " math\n", "\n", "DESCRIPTION\n", " This module is always available. It provides access to the\n", " mathematical functions defined by the C standard.\n", "\n", "FUNCTIONS\n", " acos(...)\n", " acos(x)\n", " \n", " Return the arc cosine (measured in radians) of x.\n", " \n", " acosh(...)\n", " acosh(x)\n", " \n", " Return the inverse hyperbolic cosine of x.\n", " \n", " asin(...)\n", " asin(x)\n", " \n", " Return the arc sine (measured in radians) of x.\n", " \n", " asinh(...)\n", " asinh(x)\n", " \n", " Return the inverse hyperbolic sine of x.\n", " \n", " atan(...)\n", " atan(x)\n", " \n", " Return the arc tangent (measured in radians) of x.\n", " \n", " atan2(...)\n", " atan2(y, x)\n", " \n", " Return the arc tangent (measured in radians) of y/x.\n", " Unlike atan(y/x), the signs of both x and y are considered.\n", " \n", " atanh(...)\n", " atanh(x)\n", " \n", " Return the inverse hyperbolic tangent of x.\n", " \n", " ceil(...)\n", " ceil(x)\n", " \n", " Return the ceiling of x as an Integral.\n", " This is the smallest integer >= x.\n", " \n", " copysign(...)\n", " copysign(x, y)\n", " \n", " Return a float with the magnitude (absolute value) of x but the sign \n", " of y. On platforms that support signed zeros, copysign(1.0, -0.0) \n", " returns -1.0.\n", " \n", " cos(...)\n", " cos(x)\n", " \n", " Return the cosine of x (measured in radians).\n", " \n", " cosh(...)\n", " cosh(x)\n", " \n", " Return the hyperbolic cosine of x.\n", " \n", " degrees(...)\n", " degrees(x)\n", " \n", " Convert angle x from radians to degrees.\n", " \n", " erf(...)\n", " erf(x)\n", " \n", " Error function at x.\n", " \n", " erfc(...)\n", " erfc(x)\n", " \n", " Complementary error function at x.\n", " \n", " exp(...)\n", " exp(x)\n", " \n", " Return e raised to the power of x.\n", " \n", " expm1(...)\n", " expm1(x)\n", " \n", " Return exp(x)-1.\n", " This function avoids the loss of precision involved in the direct evaluation of exp(x)-1 for small x.\n", " \n", " fabs(...)\n", " fabs(x)\n", " \n", " Return the absolute value of the float x.\n", " \n", " factorial(...)\n", " factorial(x) -> Integral\n", " \n", " Find x!. Raise a ValueError if x is negative or non-integral.\n", " \n", " floor(...)\n", " floor(x)\n", " \n", " Return the floor of x as an Integral.\n", " This is the largest integer <= x.\n", " \n", " fmod(...)\n", " fmod(x, y)\n", " \n", " Return fmod(x, y), according to platform C. x % y may differ.\n", " \n", " frexp(...)\n", " frexp(x)\n", " \n", " Return the mantissa and exponent of x, as pair (m, e).\n", " m is a float and e is an int, such that x = m * 2.**e.\n", " If x is 0, m and e are both 0. Else 0.5 <= abs(m) < 1.0.\n", " \n", " fsum(...)\n", " fsum(iterable)\n", " \n", " Return an accurate floating point sum of values in the iterable.\n", " Assumes IEEE-754 floating point arithmetic.\n", " \n", " gamma(...)\n", " gamma(x)\n", " \n", " Gamma function at x.\n", " \n", " gcd(...)\n", " gcd(x, y) -> int\n", " greatest common divisor of x and y\n", " \n", " hypot(...)\n", " hypot(x, y)\n", " \n", " Return the Euclidean distance, sqrt(x*x + y*y).\n", " \n", " isclose(...)\n", " isclose(a, b, *, rel_tol=1e-09, abs_tol=0.0) -> bool\n", " \n", " Determine whether two floating point numbers are close in value.\n", " \n", " rel_tol\n", " maximum difference for being considered \"close\", relative to the\n", " magnitude of the input values\n", " abs_tol\n", " maximum difference for being considered \"close\", regardless of the\n", " magnitude of the input values\n", " \n", " Return True if a is close in value to b, and False otherwise.\n", " \n", " For the values to be considered close, the difference between them\n", " must be smaller than at least one of the tolerances.\n", " \n", " -inf, inf and NaN behave similarly to the IEEE 754 Standard. That\n", " is, NaN is not close to anything, even itself. inf and -inf are\n", " only close to themselves.\n", " \n", " isfinite(...)\n", " isfinite(x) -> bool\n", " \n", " Return True if x is neither an infinity nor a NaN, and False otherwise.\n", " \n", " isinf(...)\n", " isinf(x) -> bool\n", " \n", " Return True if x is a positive or negative infinity, and False otherwise.\n", " \n", " isnan(...)\n", " isnan(x) -> bool\n", " \n", " Return True if x is a NaN (not a number), and False otherwise.\n", " \n", " ldexp(...)\n", " ldexp(x, i)\n", " \n", " Return x * (2**i).\n", " \n", " lgamma(...)\n", " lgamma(x)\n", " \n", " Natural logarithm of absolute value of Gamma function at x.\n", " \n", " log(...)\n", " log(x[, base])\n", " \n", " Return the logarithm of x to the given base.\n", " If the base not specified, returns the natural logarithm (base e) of x.\n", " \n", " log10(...)\n", " log10(x)\n", " \n", " Return the base 10 logarithm of x.\n", " \n", " log1p(...)\n", " log1p(x)\n", " \n", " Return the natural logarithm of 1+x (base e).\n", " The result is computed in a way which is accurate for x near zero.\n", " \n", " log2(...)\n", " log2(x)\n", " \n", " Return the base 2 logarithm of x.\n", " \n", " modf(...)\n", " modf(x)\n", " \n", " Return the fractional and integer parts of x. Both results carry the sign\n", " of x and are floats.\n", " \n", " pow(...)\n", " pow(x, y)\n", " \n", " Return x**y (x to the power of y).\n", " \n", " radians(...)\n", " radians(x)\n", " \n", " Convert angle x from degrees to radians.\n", " \n", " sin(...)\n", " sin(x)\n", " \n", " Return the sine of x (measured in radians).\n", " \n", " sinh(...)\n", " sinh(x)\n", " \n", " Return the hyperbolic sine of x.\n", " \n", " sqrt(...)\n", " sqrt(x)\n", " \n", " Return the square root of x.\n", " \n", " tan(...)\n", " tan(x)\n", " \n", " Return the tangent of x (measured in radians).\n", " \n", " tanh(...)\n", " tanh(x)\n", " \n", " Return the hyperbolic tangent of x.\n", " \n", " trunc(...)\n", " trunc(x:Real) -> Integral\n", " \n", " Truncates x to the nearest Integral toward 0. Uses the __trunc__ magic method.\n", "\n", "DATA\n", " e = 2.718281828459045\n", " inf = inf\n", " nan = nan\n", " pi = 3.141592653589793\n", " tau = 6.283185307179586\n", "\n", "FILE\n", " (built-in)\n", "\n", "\n" ] } ], "source": [ "help(math)" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "120" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "math.factorial(5)" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "720" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "math.factorial(6)" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "5" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "math.floor(5.6)" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "6" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "math.ceil(5.6)" ] }, { "cell_type": "code", "execution_count": 26, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import math as matematik" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "120" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "matematik.factorial(5)" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "5" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "matematik.floor(5.6)" ] }, { "cell_type": "code", "execution_count": 29, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from math import *" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "120" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "factorial(5)" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "6" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "floor(6.4)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from math import floor,ceil" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "ename": "NameError", "evalue": "name 'factorial' is not defined", "output_type": "error", "traceback": [ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mfactorial\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[1;31mNameError\u001b[0m: name 'factorial' is not defined" ] } ], "source": [ "factorial(5)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "5" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "floor(5.6)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "7" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ceil(6.1)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "def factorial(sayı):\n", " print(\"Benim fonksiyonum\")\n", " \n", " faktoriyel = 1\n", " if (sayı == 0 or sayı == 1):\n", " return 1\n", " else:\n", " while (sayı >= 1):\n", " faktoriyel *= sayı\n", " sayı -= 1\n", " return faktoriyel" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from math import *" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "120" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "factorial(5)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "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 }