{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Lab 5\n", "\n", "How to verify if a number is a possible credit card number?\n", "In order to verify the check digit is correct, verify the following steps:\n", "\n", "* Supose the following number=\"5105105105105100\".\n", "* Convert the number into a list\n", "* Reverse the List\n", "* Starting from the left digit, double every second digit.\n", "* If double of a digit is more than 9, add the digits.\n", "* Sum all the numbers except the first one multiply by 9 and remove the unit\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Start by converting the number into a list\n", "number=\"5105105105105100\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#convert a number into a list\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Convert stings into integers\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Starting from the left digit, double every second digit.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# If double of a digit is more then 9, add the digits.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Sum all the numbers except the first one\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# multiply by 9 and remove the unit\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If the last number of variable numer is the same you reached, the check digit of the credit card is correct" ] } ], "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.0" } }, "nbformat": 4, "nbformat_minor": 2 }