{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "K_wAO80MMmPw" }, "source": [ "# Hello World!" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "9wKvlBG4Mcrw", "outputId": "4f6a12e7-530a-4229-9c4c-921f5f7fb1f4" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Hello World!\n" ] } ], "source": [ "print(\"Hello, World!\")" ] }, { "cell_type": "markdown", "metadata": { "id": "42HQoSIQ6yAO" }, "source": [ "```python\n", "print(*objects, sep=' ', end='\\n')\n", "```\n", "Print `objects` to the text stream, separated by `sep` and followed by `end`. `sep` and `end`, if present, must be given as keyword arguments ... Both `sep` and `end` must be `strings`; they can also be `None`, which means to use the default values. If no objects are given, `print()` will just write `end`.\n" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "gAPnJ-FN7N0A", "outputId": "feac9cfa-3d5b-4b37-921c-a8db62eb44ca" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The answer of the sum 6 + 7 is 13 , do you agree?\n", "The answer of 5 + 8 = 13\n" ] } ], "source": [ "print(\"The answer of the sum 6 + 7 is\", 6 + 7, \", do you agree?\")\n", "\n", "#now we print the values of the variables\n", "s = \"The answer of\"\n", "a = 5\n", "b = 8\n", "c = a + b\n", "print(s, a, \"+\", b, \"=\", c)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "NubHus3x7xso", "outputId": "12c21c3c-ec4f-4f73-b774-5293cc8034af" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "we--can--define--a--different--sep\n", "we\n", "can\n", "define\n", "a\n", "different\n", "sep\n" ] } ], "source": [ "#different separator\n", "print(\"we\", \"can\", \"define\", \"a\", \"different\", \"sep\", sep=\"--\")\n", "\n", "# \\n is the new line\n", "print(\"we\", \"can\", \"define\", \"a\", \"different\", \"sep\", sep=\"\\n\")" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "NI4Hr6kRBD0X", "outputId": "4f2e668c-c11d-4823-a979-1e64c55e9287" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Hello\n", "World!\n", "\n", "Hello World!\n" ] } ], "source": [ "#by default, at the end of the print we have a new line\n", "print(\"Hello\")\n", "print(\"World!\")\n", "\n", "#if nothing indicated (None value), then only end is printed\n", "print()\n", "\n", "# but we can change it!\n", "print(\"Hello\", end=\" \")\n", "print(\"World!\")" ] } ], "metadata": { "colab": { "provenance": [] }, "kernelspec": { "display_name": "Python 3", "name": "python3" }, "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 0 }