{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "x = 12 # 104836" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "x is divisible by 6\n" ] } ], "source": [ "if x % 6 == 0:\n", " print('x is divisible by 6')\n", "elif x % 2 == 0:\n", " print('x is divisible by 2')\n", "elif x % 3 == 0:\n", " print('x is divisible by 3')\n", "else:\n", " print('x is not divisible by 2 or 3')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "if x % 6 == 0:\n", " with open('output.txt', 'w') as f:\n", " f.write('x is divisible by 6')\n", "elif x % 2 == 0:\n", " with open('output.txt', 'w') as f:\n", " f.write('x is divisible by 2')\n", "elif x % 3 == 0:\n", " with open('output.txt', 'w') as f:\n", " f.write('x is divisible by 3')\n", "else:\n", " with open('output.txt', 'w') as f:\n", " f.write('x is not divisible by 2 or 3')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "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.7.4" } }, "nbformat": 4, "nbformat_minor": 2 }