Created
December 21, 2021 19:07
-
-
Save brt-h/78acbf7c6fe7a88ae14ed11cda5bac32 to your computer and use it in GitHub Desktop.
12-21-21-python-challenges-from-edabit.ipynb
This file contains 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": { | |
"name": "12-21-21-python-challenges-from-edabit.ipynb", | |
"provenance": [], | |
"collapsed_sections": [], | |
"authorship_tag": "ABX9TyMSB//vzt5yrtLN6oV5IckC", | |
"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/brt-h/78acbf7c6fe7a88ae14ed11cda5bac32/12-21-21-python-challenges-from-edabit.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"# Omnipresent Value https://edabit.com/challenge/cqucnDiDA5J5vjGAJ\n", | |
"def is_omnipresent(lst, val):\n", | |
"\tx=1\n", | |
"\tfor row in lst:\n", | |
"\t\tif val in row:\n", | |
"\t\t\tcontinue\n", | |
"\t\telse:\n", | |
"\t\t\tx=0\n", | |
"\t\t\tcontinue\n", | |
"\tif x==1:\n", | |
"\t\treturn(True)\n", | |
"\telse:\n", | |
"\t\treturn(False)" | |
], | |
"metadata": { | |
"id": "d4ByEEf1YWdu" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"# Sum of Resistance in Series Circuits https://edabit.com/challenge/gzmFeaXwFv8X6pBGq\n", | |
"def series_resistance(lst):\n", | |
"\tRT=0\n", | |
"\tfor resistor in lst:\n", | |
"\t\tRT=RT+resistor\n", | |
"\tsuffix=\" ohm\"\n", | |
"\tif RT > 1:\n", | |
"\t\tsuffix=\" ohms\"\n", | |
"\treturn(\n", | |
"\t\"{}{}\".format(RT,suffix)\n", | |
"\t)" | |
], | |
"metadata": { | |
"id": "p0FUn79CxlcW" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"# End Corona! https://edabit.com/challenge/uKPc5faEzQkMwLYPP\n", | |
"def end_corona(recovers, new_cases, active_cases):\n", | |
"\timport math\n", | |
"\tdelta = recovers-new_cases\n", | |
"\tdays = active_cases/delta\n", | |
"\treturn(math.ceil(days))" | |
], | |
"metadata": { | |
"id": "uflloTPgHK9-" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"# Basic Calculator https://edabit.com/challenge/ZdnwC3PsXPQTdTiKf\n", | |
"def calculator(num1, operator, num2):\n", | |
"\tif num2 == 0:\n", | |
"\t\treturn(\"Can't divide by 0!\")\n", | |
"\telse:\n", | |
"\t\tcalculation = str(num1)+str(operator)+str(num2)\n", | |
"\t\treturn(eval(calculation))" | |
], | |
"metadata": { | |
"id": "xvKmmA-JHLC4" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"# How Heavy Is [A Cylinder Full Of Water]? https://edabit.com/challenge/iP4ixkQffELyHvHi5\n", | |
"def weight(r, h):\n", | |
"\timport math\n", | |
"\tV = math.pi * (r**2) * h # cm^3\n", | |
"\tV = V/1000 # dm^3\n", | |
"\treturn(round(V, 2))" | |
], | |
"metadata": { | |
"id": "WYZyOzSDJcnB" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"# Default Mood https://edabit.com/challenge/tgEWKRQD8hu5dD3pX\n", | |
"def mood_today(mood=\"neutral\"):\n", | |
"\treturn(\"Today, I am feeling {}\".format(mood))" | |
], | |
"metadata": { | |
"id": "bm33xhzxL0Mi" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment