{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "class Araba():\n", " model = \"Renault Megane\"\n", " renk = \"Gümüş\"\n", " beygir_gücü = 110\n", " silindir = 4\n", " " ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "araba1 = Araba()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "<__main__.Araba at 0x6ba743f7b8>" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "araba1" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "araba2 = Araba()" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "<__main__.Araba at 0x6ba743f9e8>" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "araba2" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Renault Megane'" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "araba1.model" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "110" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "araba2.beygir_gücü" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Renault Megane'" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "araba2.model" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Renault Megane'" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Araba.model" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "110" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Araba.beygir_gücü" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['__class__',\n", " '__delattr__',\n", " '__dict__',\n", " '__dir__',\n", " '__doc__',\n", " '__eq__',\n", " '__format__',\n", " '__ge__',\n", " '__getattribute__',\n", " '__gt__',\n", " '__hash__',\n", " '__init__',\n", " '__init_subclass__',\n", " '__le__',\n", " '__lt__',\n", " '__module__',\n", " '__ne__',\n", " '__new__',\n", " '__reduce__',\n", " '__reduce_ex__',\n", " '__repr__',\n", " '__setattr__',\n", " '__sizeof__',\n", " '__str__',\n", " '__subclasshook__',\n", " '__weakref__',\n", " 'beygir_gücü',\n", " 'model',\n", " 'renk',\n", " 'silindir']" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dir(araba1)" ] }, { "cell_type": "code", "execution_count": 52, "metadata": { "collapsed": true }, "outputs": [], "source": [ "class Araba():\n", " \n", " def __init__(self,model,renk,beygir_gücü,silindir):\n", " print(\"init fonksiyonu çağrıldı\")\n", " self.model = model\n", " self.renk = renk\n", " self.beygir_gücü = beygir_gücü\n", " self.silindir = silindir\n", " \n", " " ] }, { "cell_type": "code", "execution_count": 53, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "init fonksiyonu çağrıldı\n" ] } ], "source": [ "araba1 = Araba(\"Renault Megane\",\"Gümüş\",110,4)" ] }, { "cell_type": "code", "execution_count": 54, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "init fonksiyonu çağrıldı\n" ] } ], "source": [ "araba2 = Araba(\"Peugeot\",\"Beyaz\",90,4)" ] }, { "cell_type": "code", "execution_count": 55, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Renault Megane'" ] }, "execution_count": 55, "metadata": {}, "output_type": "execute_result" } ], "source": [ "araba1.model" ] }, { "cell_type": "code", "execution_count": 56, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Peugeot'" ] }, "execution_count": 56, "metadata": {}, "output_type": "execute_result" } ], "source": [ "araba2.model" ] }, { "cell_type": "code", "execution_count": 57, "metadata": { "collapsed": true }, "outputs": [], "source": [ "class Araba():\n", " \n", " def __init__(self,model = \"Bilgi Yok\",renk = \"Bilgi Yok\",beygir_gücü = 70,silindir = 4):\n", " print(\"init fonksiyonu çağrıldı\")\n", " self.model = model\n", " self.renk = renk\n", " self.beygir_gücü = beygir_gücü\n", " self.silindir = silindir" ] }, { "cell_type": "code", "execution_count": 58, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "init fonksiyonu çağrıldı\n" ] } ], "source": [ "araba = Araba(beygir_gücü = 110)" ] }, { "cell_type": "code", "execution_count": 59, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Bilgi Yok'" ] }, "execution_count": 59, "metadata": {}, "output_type": "execute_result" } ], "source": [ "araba.model" ] }, { "cell_type": "code", "execution_count": 60, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "110" ] }, "execution_count": 60, "metadata": {}, "output_type": "execute_result" } ], "source": [ "araba.beygir_gücü" ] }, { "cell_type": "code", "execution_count": 67, "metadata": { "collapsed": true }, "outputs": [], "source": [ "def terscevir(s):\n", " if (type(s) == int):\n", " raise TypeError(\"Lütfen string bir değer girin.\")" ] }, { "cell_type": "code", "execution_count": 69, "metadata": {}, "outputs": [ { "ename": "TypeError", "evalue": "Lütfen string bir değer girin.", "output_type": "error", "traceback": [ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mTypeError\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[0mterscevir\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m35\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[1;32m\u001b[0m in \u001b[0;36mterscevir\u001b[1;34m(s)\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mterscevir\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[1;32mif\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mtype\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m==\u001b[0m \u001b[0mint\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 3\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Lütfen string bir değer girin.\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[1;31mTypeError\u001b[0m: Lütfen string bir değer girin." ] } ], "source": [ "terscevir(35)" ] }, { "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 }