Last active
October 18, 2025 14:53
-
-
Save MuhammetOzturk/fd9d764d71a4873128ab881bc36141cd to your computer and use it in GitHub Desktop.
Javascript-1.ipynb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "nbformat": 4, | |
| "nbformat_minor": 0, | |
| "metadata": { | |
| "colab": { | |
| "provenance": [], | |
| "authorship_tag": "ABX9TyPZTbm2RECfcaaM98Keirdl", | |
| "include_colab_link": true | |
| }, | |
| "kernelspec": { | |
| "name": "python3", | |
| "display_name": "Python 3" | |
| }, | |
| "language_info": { | |
| "name": "python" | |
| } | |
| }, | |
| "cells": [ | |
| { | |
| "cell_type": "markdown", | |
| "metadata": { | |
| "id": "view-in-github", | |
| "colab_type": "text" | |
| }, | |
| "source": [ | |
| "<a href=\"https://colab.research.google.com/gist/MuhammetOzturk/fd9d764d71a4873128ab881bc36141cd/javascript-1.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 66, | |
| "metadata": { | |
| "id": "VSwxpf-xmfmw" | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "from IPython.display import Javascript\n", | |
| "from IPython.display import display, HTML" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "jscode = \"\"\"\n", | |
| "p=document.createElement(\"p\");\n", | |
| "p.innerHTML=\"Hello World\";\n", | |
| "document.body.appendChild(p);M\n", | |
| "\"\"\"\n", | |
| "print(\"Hello\")\n", | |
| "display(Javascript(jscode))\n", | |
| "print(\"World\")" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/", | |
| "height": 81 | |
| }, | |
| "id": "B8cmPJmlms8X", | |
| "outputId": "7748e1db-c651-42fb-96a2-ad3d312ca2d8" | |
| }, | |
| "execution_count": 67, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "Hello\n" | |
| ] | |
| }, | |
| { | |
| "output_type": "display_data", | |
| "data": { | |
| "text/plain": [ | |
| "<IPython.core.display.Javascript object>" | |
| ], | |
| "application/javascript": [ | |
| "\n", | |
| "p=document.createElement(\"p\");\n", | |
| "p.innerHTML=\"Hello World\";\n", | |
| "document.body.appendChild(p);M\n" | |
| ] | |
| }, | |
| "metadata": {} | |
| }, | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "World\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "jscode = \"\"\"\n", | |
| "input=document.createElement(\"input\");\n", | |
| "input.type=\"text\";\n", | |
| "input.placeHolder=\"Enter Text\";\n", | |
| "input.id=\"myText\";\n", | |
| "input.addEventListener(\"keydown\",function(event){\n", | |
| " if(event.key==\"Enter\"){\n", | |
| " p=document.createElement(\"p\");\n", | |
| " p.innerHTML=document.getElementById(\"myText\").value;\n", | |
| " document.body.appendChild(p);\n", | |
| " document.getElementById(\"myText\").value=\"\";\n", | |
| " }\n", | |
| "})\n", | |
| "document.body.appendChild(input);\n", | |
| "\n", | |
| "\"\"\"\n", | |
| "display(Javascript(jscode))" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/", | |
| "height": 89 | |
| }, | |
| "id": "N4FDvwgQoS_H", | |
| "outputId": "141e4128-297c-4a12-93ab-ab424684504e" | |
| }, | |
| "execution_count": 68, | |
| "outputs": [ | |
| { | |
| "output_type": "display_data", | |
| "data": { | |
| "text/plain": [ | |
| "<IPython.core.display.Javascript object>" | |
| ], | |
| "application/javascript": [ | |
| "\n", | |
| "input=document.createElement(\"input\");\n", | |
| "input.type=\"text\";\n", | |
| "input.placeHolder=\"Enter Text\";\n", | |
| "input.id=\"myText\";\n", | |
| "input.addEventListener(\"keydown\",function(event){\n", | |
| " if(event.key==\"Enter\"){\n", | |
| " p=document.createElement(\"p\");\n", | |
| " p.innerHTML=document.getElementById(\"myText\").value;\n", | |
| " document.body.appendChild(p);\n", | |
| " document.getElementById(\"myText\").value=\"\";\n", | |
| " }\n", | |
| "})\n", | |
| "document.body.appendChild(input);\n", | |
| "\n" | |
| ] | |
| }, | |
| "metadata": {} | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "jscode = \"\"\"\n", | |
| "input=document.createElement(\"input\");\n", | |
| "input.type=\"text\";\n", | |
| "input.placeHolder=\"Enter Text\";\n", | |
| "input.id=\"myText\";\n", | |
| "input.addEventListener(\"keydown\",function(event){\n", | |
| " if(event.key==\"Enter\"){\n", | |
| " line = document.getElementById(\"line\");\n", | |
| " if(line){\n", | |
| " line.remove();\n", | |
| " }\n", | |
| " p=document.createElement(\"p\");\n", | |
| " p.id = \"line\";\n", | |
| " p.innerHTML=document.getElementById(\"myText\").value;\n", | |
| " document.body.appendChild(p);\n", | |
| " document.getElementById(\"myText\").value=\"\";\n", | |
| " }\n", | |
| "})\n", | |
| "document.body.appendChild(input);\n", | |
| "\n", | |
| "\"\"\"\n", | |
| "display(Javascript(jscode))" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/", | |
| "height": 65 | |
| }, | |
| "id": "43nrg8wTpf9X", | |
| "outputId": "ce6ff579-b451-4bba-dc16-f311b01e447c" | |
| }, | |
| "execution_count": 69, | |
| "outputs": [ | |
| { | |
| "output_type": "display_data", | |
| "data": { | |
| "text/plain": [ | |
| "<IPython.core.display.Javascript object>" | |
| ], | |
| "application/javascript": [ | |
| "\n", | |
| "input=document.createElement(\"input\");\n", | |
| "input.type=\"text\";\n", | |
| "input.placeHolder=\"Enter Text\";\n", | |
| "input.id=\"myText\";\n", | |
| "input.addEventListener(\"keydown\",function(event){\n", | |
| " if(event.key==\"Enter\"){\n", | |
| " line = document.getElementById(\"line\");\n", | |
| " if(line){\n", | |
| " line.remove();\n", | |
| " }\n", | |
| " p=document.createElement(\"p\");\n", | |
| " p.id = \"line\";\n", | |
| " p.innerHTML=document.getElementById(\"myText\").value;\n", | |
| " document.body.appendChild(p);\n", | |
| " document.getElementById(\"myText\").value=\"\";\n", | |
| " }\n", | |
| "})\n", | |
| "document.body.appendChild(input);\n", | |
| "\n" | |
| ] | |
| }, | |
| "metadata": {} | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "#@title Hesap Makinesi\n", | |
| "\n", | |
| "jscode = \"\"\"\n", | |
| "// ilk sayi\n", | |
| "input = document.createElement(\"input\");\n", | |
| "input.type=\"text\";\n", | |
| "input.placeHolder=\"Enter Text\";\n", | |
| "input.id=\"sayi1\";\n", | |
| "input.style.width=\"50px\";\n", | |
| "input.style.height=\"30px\";\n", | |
| "input.style.textAlign=\"center\";\n", | |
| "input.style.margin=\"5px\";\n", | |
| "document.body.appendChild(input);\n", | |
| "\n", | |
| "// operator\n", | |
| "input = document.createElement(\"input\");\n", | |
| "input.type=\"text\";\n", | |
| "input.placeHolder=\"Islem\";\n", | |
| "input.id=\"islem\";\n", | |
| "input.style.width=\"50px\";\n", | |
| "input.style.height=\"30px\";\n", | |
| "input.style.textAlign=\"center\";\n", | |
| "input.style.margin=\"5px\";\n", | |
| "document.body.appendChild(input);\n", | |
| "\n", | |
| "//ikinci sayi\n", | |
| "input = document.createElement(\"input\");\n", | |
| "input.type=\"text\";\n", | |
| "input.placeHolder=\"Enter Text\";\n", | |
| "input.id=\"sayi2\";\n", | |
| "input.style.width=\"50px\";\n", | |
| "input.style.height=\"30px\";\n", | |
| "input.style.textAlign=\"center\";\n", | |
| "input.style.margin=\"5px\";\n", | |
| "document.body.appendChild(input);\n", | |
| "\n", | |
| "// span\n", | |
| "span = document.createElement(\"span\");\n", | |
| "span.innerHTML = \"=\";\n", | |
| "span.style.margin=\"5px\";\n", | |
| "document.body.appendChild(span);\n", | |
| "\n", | |
| "// sonuc\n", | |
| "span = document.createElement(\"span\");\n", | |
| "//span.id = \"sonuc\";\n", | |
| "span.innerHTML = \"\";\n", | |
| "span.style.margin=\"5px\";\n", | |
| "document.body.appendChild(span);\n", | |
| "\n", | |
| "let inputs = document.querySelectorAll(\"input\");\n", | |
| "inputs.forEach(input => {\n", | |
| " input.addEventListener(\"keydown\",function(event){\n", | |
| " if(event.key==\"Enter\"){\n", | |
| " let sayi1 = document.getElementById(\"sayi1\").value;\n", | |
| " let sayi2 = document.getElementById(\"sayi2\").value;\n", | |
| " let islem = document.getElementById(\"islem\").value;\n", | |
| " if(islem == \"+\"){\n", | |
| " span.innerHTML = parseInt(sayi1) + parseInt(sayi2);\n", | |
| " }\n", | |
| " if(islem == \"-\"){\n", | |
| " span.innerHTML = parseInt(sayi1) - parseInt(sayi2);\n", | |
| " }\n", | |
| " if(islem == \"*\"){\n", | |
| " span.innerHTML = parseInt(sayi1) * parseInt(sayi2);\n", | |
| " }\n", | |
| " if(islem == \"/\"){\n", | |
| " span.innerHTML = parseInt(sayi1) / parseInt(sayi2);\n", | |
| " }\n", | |
| "\n", | |
| " }\n", | |
| " })\n", | |
| "})\n", | |
| "\"\"\"\n", | |
| "\n", | |
| "display(Javascript(jscode))" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/", | |
| "height": 61 | |
| }, | |
| "id": "kIqyX7dUn8BE", | |
| "outputId": "bc36d451-eb7a-4b8a-e668-701b4e2fe31d" | |
| }, | |
| "execution_count": 70, | |
| "outputs": [ | |
| { | |
| "output_type": "display_data", | |
| "data": { | |
| "text/plain": [ | |
| "<IPython.core.display.Javascript object>" | |
| ], | |
| "application/javascript": [ | |
| "\n", | |
| "// ilk sayi\n", | |
| "input = document.createElement(\"input\");\n", | |
| "input.type=\"text\";\n", | |
| "input.placeHolder=\"Enter Text\";\n", | |
| "input.id=\"sayi1\";\n", | |
| "input.style.width=\"50px\";\n", | |
| "input.style.height=\"30px\";\n", | |
| "input.style.textAlign=\"center\";\n", | |
| "input.style.margin=\"5px\";\n", | |
| "document.body.appendChild(input);\n", | |
| "\n", | |
| "// operator\n", | |
| "input = document.createElement(\"input\");\n", | |
| "input.type=\"text\";\n", | |
| "input.placeHolder=\"Islem\";\n", | |
| "input.id=\"islem\";\n", | |
| "input.style.width=\"50px\";\n", | |
| "input.style.height=\"30px\";\n", | |
| "input.style.textAlign=\"center\";\n", | |
| "input.style.margin=\"5px\";\n", | |
| "document.body.appendChild(input);\n", | |
| "\n", | |
| "//ikinci sayi\n", | |
| "input = document.createElement(\"input\");\n", | |
| "input.type=\"text\";\n", | |
| "input.placeHolder=\"Enter Text\";\n", | |
| "input.id=\"sayi2\";\n", | |
| "input.style.width=\"50px\";\n", | |
| "input.style.height=\"30px\";\n", | |
| "input.style.textAlign=\"center\";\n", | |
| "input.style.margin=\"5px\";\n", | |
| "document.body.appendChild(input);\n", | |
| "\n", | |
| "// span\n", | |
| "span = document.createElement(\"span\");\n", | |
| "span.innerHTML = \"=\";\n", | |
| "span.style.margin=\"5px\";\n", | |
| "document.body.appendChild(span);\n", | |
| "\n", | |
| "// sonuc\n", | |
| "span = document.createElement(\"span\");\n", | |
| "//span.id = \"sonuc\";\n", | |
| "span.innerHTML = \"\";\n", | |
| "span.style.margin=\"5px\";\n", | |
| "document.body.appendChild(span);\n", | |
| "\n", | |
| "let inputs = document.querySelectorAll(\"input\");\n", | |
| "inputs.forEach(input => {\n", | |
| " input.addEventListener(\"keydown\",function(event){\n", | |
| " if(event.key==\"Enter\"){\n", | |
| " let sayi1 = document.getElementById(\"sayi1\").value;\n", | |
| " let sayi2 = document.getElementById(\"sayi2\").value;\n", | |
| " let islem = document.getElementById(\"islem\").value;\n", | |
| " if(islem == \"+\"){\n", | |
| " span.innerHTML = parseInt(sayi1) + parseInt(sayi2);\n", | |
| " }\n", | |
| " if(islem == \"-\"){\n", | |
| " span.innerHTML = parseInt(sayi1) - parseInt(sayi2);\n", | |
| " }\n", | |
| " if(islem == \"*\"){\n", | |
| " span.innerHTML = parseInt(sayi1) * parseInt(sayi2);\n", | |
| " }\n", | |
| " if(islem == \"/\"){\n", | |
| " span.innerHTML = parseInt(sayi1) / parseInt(sayi2);\n", | |
| " }\n", | |
| "\n", | |
| " }\n", | |
| " })\n", | |
| "})\n" | |
| ] | |
| }, | |
| "metadata": {} | |
| } | |
| ] | |
| } | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment